Movatterモバイル変換


[0]ホーム

URL:


krmboya, profile picture
Uploaded bykrmboya
PDF, PPTX1,012 views

Python bootcamp - C4Dlab, University of Nairobi

This document summarizes a Python bootcamp presentation covering the basics of Python including features, common uses in industry, data types, operators, strings, lists, dictionaries, functions, modules, file I/O, and accessing the web. It provides examples of Python code and concludes with next steps and resources for further learning Python.

Embed presentation

Download as PDF, PPTX
Python Bootcamp - C4Dlab             SCI labs, University of Nairobi             Nov 24th 2013             Kenny Rachuonyo
Introduction to Python    Features of Python●   Simplicity - pseudocode●   Free and Open Source - community●   High-level – no low-level mngt●   Interpreted – run from source●   Object-Oriented – simple to use●   Extensible – C/C++
Features (cont.)●   Embeddable – games, graphics,●   Extensive Libraries (batteries included) – data    compression, OS, Networking, Internet,    Multimedia, Graphics
Python in the Industry    Web●   Google – Youtube, backend tasks..●   Reddit – news aggregation site●   Disqus – commenting service●   Numerous web frameworks – django, Zope,    webapp2, web.py, pyramid, flask
Python in the Industry    Desktop●   Games – Counterstrike, Civilization IV●   Cinema 4D – Graphics●   Dropbox●   GUI frameworks – PyGTK, PyQT,
Python in the Industry    Scientific Computing●   NASA●   Packages: Scipy, Numpy, Matplotlib,
Python in the Industry    Mobile●   Nokia Symbian Series 60●   Android – Scripting Layer for Android●   Blackberry●   Kivy – cross-platform: iOS, Android, Linux,    Windows, Mac
Python Basics●   The interpreter    –   Installation    –   Windows (set path)●   Datatypes: int, str, float, lists, tuples,    dictionaries●   Basic I/O
Python Basics●   Variables    –   Dynamically-typed vs statically-typed          >>> x = 1          >>>y = “hello”    –   Strongly-typed          >>> x + y●   Type function          >>> type(x)●   Integer vs float          >>> z = 1.0
Python BasicsOperator          Operation+                 Addition-                 Subtraction/                 Division*                 Multiplication**                Power%                 Modulus
Python Basics●   How will this be evaluated?        >>>X = 1 + 2 – 3 ** 4 * ( 5+6)
Python Basics●   Operator Precedence rules    Parenthesis    Power    Multiplication    Addition    Left-to-right
Python Basics●   Integer division         >>> 4/2         >>> 5/2●   Mixing integer and floats         >>> 5/2.0●   Casting between integer and floats         >>> float(5)         >>>int(5.0)
Python Basics    Strings – sequence of characters         >>> s = “hello world”●   Looking inside         >>> s[0]●   Concatenation         >>> s = ”hello ” + “world”●   Finding length         >>> len(s)●   Slicing         >>> s = s[0:5]
Python Basics    Handy String functions●   find           >>> s.find('e')●   Replace           >>> n = s.replace('e', 'a' )●   Make upper, lower           >>> u = s.upper()
Python Basics●   Get the second word 'world' by slicing        >>> “hello, world”[x:y]
Python Basics    Lists – collection of values●   Declaring        >>> l = list()        >>> l = []●   Can hold different types        >>> l = [1, 'a', [2, 3], 4]        >>> l[2]●   Appending        >>> l.append('an item')        >>>del(l[2])
Python Basics    Lists – collection of values●   Getting length         >>> len(l)●   Slicing         >>> l[1:4]●   Converting between strings and lists         >>> strlist = “this is a string”.split('s')         >>> “z”.join(strlist)
Python Basics●   Append an item to the list within the list         >>> l = [1, 'a', [2, 3], 4]         >>> l = [1, 'a', [2, 3, 5], 4]
Python Basics●   Handy functions    Sum          >>> sum([2, 3, 4])    Max          >>> max([2, 3, 4])    Min          >>> min([2, 3, 4])
Python Basics    Dictionaries – key, value pairs    Associative array, hash table●   Declaring        >>> d = dict()        >>> d = {}●   Setting a value        >>> d[“event”] = “bootcamp”        >>> d = {“event” : “bootcamp” }●   Getting a value        >>> d[“event”]
Python Basics    Mutability●   Mutable – can change    –   Lists, dictionary●   Immutable – cannot change    –   Strings, tuples●   Try set, del..
Python Basics    Casting – numbers and strings●   Strings and numbers        >>> int(“234”)        >>> str(234)
Python Basics●   Importing modules         >>> import math         >>> math.sqrt(4)         >>> from math import sqrt         >>> sqrt(4)●   dir() function         >>> dir(math)
Python Basics●   Basic I/O        >>> name = raw_input()        >>> name = raw_input(“Name: “)    Input numbers:        >>>age = raw_input(“Age: “)        >>>age = int(raw_input(“Age: “))
Modules●   Interactive mode vs modules●   Indentation
Boolean Values●   True           >>> 1 < 2●   False           >>> 1 > 2●   Also evaluate to False:      “”, [], {}, 0
Loops●   While loop – while condition is true         x=0         while x < 10:           print x           x=x+1●   For loop – loops over items         words = ['this' , 'is', 'a', 'list']         for w in words:            print w●   Loop over strings, dictionaries..●   Range() function         >>> range(3)         >>> range(0, 10, 2)
Functions●   Defining functions        def say_hello():          print “hello”●   Calling functions        say_hello()●   Parameters        def sub(a, b):          s=a-b          return s        sub(b=3, a=2)
Functions●   Commenting in Python        def sub(a, b):          d = a – b #subtracts b from a          return d●   Doc strings        def sub(a, b):           “””this functions takes in 2 integers and returns their        difference”””          d=a–b          return d
File I/O●   Writing to a file         f = open('text.txt', 'wb')         f.write('This is a line.n')         f.close()●   Reading a file         f = open('text.txt', 'rb')         stream = f.read()         f.close()
Accessing the Web●   Establishing a connection    –   sockets●   Requests and Responses    –   GET, retrieve a webpage    –   POST, save data●   Download a webpage          fopen = urllib.urlopen(“http://www.google.com”)          data = fopen.read()
Demo●   Web demo●   Scientific computing
Next Steps●   Intermediate topics:    –   Classes and objects in Python    –   Regular Expressions    –   Exceptions etc●   Python on Appengine●   Python user group
Resources●   Official Python Docs tutorial      http://docs.python.org/2/tutorial/●   A byte of Python      http://www.swaroopch.com/notes/python/●   Think like a Computer Scientist      http://www.openbookproject.net/thinkcs/python/english2e/

Recommended

PDF
Python tour
ODP
Introduction to R
PDF
Python in 90 minutes
PDF
Pune Clojure Course Outline
PDF
TeraSort
ODP
Python Day1
PPTX
Basics of Python programming (part 2)
KEY
Clojure Intro
PDF
Comparing JVM languages
PDF
Python dictionary : past, present, future
ODP
Python internals and how they affect your code - kasra ahmadvand
PDF
Hammurabi
PDF
Python for Dummies
PPT
Initial Java Core Concept
PDF
Kotlin Slides from Devoxx 2011
PDF
Idiomatic Kotlin
PPTX
Scala - where objects and functions meet
PDF
Swift for TensorFlow - CoreML Personalization
PDF
Becoming a Pythonist
PDF
Introduction to Functional Programming
PDF
C# - What's next
PDF
Python Cheat Sheet
PDF
Kotlin, why?
PPTX
Java 7, 8 & 9 - Moving the language forward
PPT
OOP Core Concept
PPTX
Python Training
PDF
Communicating State Machines
PDF
Humble introduction to category theory in haskell
PDF
UNIVERSITY OF NAIROBI PROJECT
PPTX
Cloud computing in kenya

More Related Content

PDF
Python tour
ODP
Introduction to R
PDF
Python in 90 minutes
PDF
Pune Clojure Course Outline
PDF
TeraSort
ODP
Python Day1
PPTX
Basics of Python programming (part 2)
KEY
Clojure Intro
Python tour
Introduction to R
Python in 90 minutes
Pune Clojure Course Outline
TeraSort
Python Day1
Basics of Python programming (part 2)
Clojure Intro

What's hot

PDF
Comparing JVM languages
PDF
Python dictionary : past, present, future
ODP
Python internals and how they affect your code - kasra ahmadvand
PDF
Hammurabi
PDF
Python for Dummies
PPT
Initial Java Core Concept
PDF
Kotlin Slides from Devoxx 2011
PDF
Idiomatic Kotlin
PPTX
Scala - where objects and functions meet
PDF
Swift for TensorFlow - CoreML Personalization
PDF
Becoming a Pythonist
PDF
Introduction to Functional Programming
PDF
C# - What's next
PDF
Python Cheat Sheet
PDF
Kotlin, why?
PPTX
Java 7, 8 & 9 - Moving the language forward
PPT
OOP Core Concept
PPTX
Python Training
PDF
Communicating State Machines
PDF
Humble introduction to category theory in haskell
Comparing JVM languages
Python dictionary : past, present, future
Python internals and how they affect your code - kasra ahmadvand
Hammurabi
Python for Dummies
Initial Java Core Concept
Kotlin Slides from Devoxx 2011
Idiomatic Kotlin
Scala - where objects and functions meet
Swift for TensorFlow - CoreML Personalization
Becoming a Pythonist
Introduction to Functional Programming
C# - What's next
Python Cheat Sheet
Kotlin, why?
Java 7, 8 & 9 - Moving the language forward
OOP Core Concept
Python Training
Communicating State Machines
Humble introduction to category theory in haskell

Viewers also liked

PDF
UNIVERSITY OF NAIROBI PROJECT
PPTX
Cloud computing in kenya
PPTX
Mt. Everest-eLearning & Gamification Innovation-Keynote
DOCX
Ici final-project (Individual)
 
PDF
What Really Matters in The Digital Learning Project 2013
PDF
IoT Smart APIs using Nomos RuleX
UNIVERSITY OF NAIROBI PROJECT
Cloud computing in kenya
Mt. Everest-eLearning & Gamification Innovation-Keynote
Ici final-project (Individual)
 
What Really Matters in The Digital Learning Project 2013
IoT Smart APIs using Nomos RuleX

Similar to Python bootcamp - C4Dlab, University of Nairobi

PPT
PDF
Python: An introduction A summer workshop
PDF
Python intro
PPTX
Python Workshop - Learn Python the Hard Way
PPTX
Introduction to Python programming Language
PPTX
IoT-Week1-Day1-Lab.pptx
PDF
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
PDF
Python Part 1
PDF
Introduction To Programming with Python
PDF
Introduction to Python
PPTX
python_computer engineering_semester_computer_language.pptx
ODP
An Intro to Python in 30 minutes
PDF
First Steps in Python Programming
PPTX
funadamentals of python programming language (right from scratch)
PPTX
Python Demo.pptx
PPTX
Python Demo.pptx
PDF
ppt_pspp.pdf
PDF
Introduction to python
PPTX
Python bible
PDF
Python Cheatsheet_A Quick Reference Guide for Data Science.pdf
Python: An introduction A summer workshop
Python intro
Python Workshop - Learn Python the Hard Way
Introduction to Python programming Language
IoT-Week1-Day1-Lab.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
Python Part 1
Introduction To Programming with Python
Introduction to Python
python_computer engineering_semester_computer_language.pptx
An Intro to Python in 30 minutes
First Steps in Python Programming
funadamentals of python programming language (right from scratch)
Python Demo.pptx
Python Demo.pptx
ppt_pspp.pdf
Introduction to python
Python bible
Python Cheatsheet_A Quick Reference Guide for Data Science.pdf

Python bootcamp - C4Dlab, University of Nairobi

  • 1.
    Python Bootcamp -C4Dlab SCI labs, University of Nairobi Nov 24th 2013 Kenny Rachuonyo
  • 2.
    Introduction to Python Features of Python● Simplicity - pseudocode● Free and Open Source - community● High-level – no low-level mngt● Interpreted – run from source● Object-Oriented – simple to use● Extensible – C/C++
  • 3.
    Features (cont.)● Embeddable – games, graphics,● Extensive Libraries (batteries included) – data compression, OS, Networking, Internet, Multimedia, Graphics
  • 4.
    Python in theIndustry Web● Google – Youtube, backend tasks..● Reddit – news aggregation site● Disqus – commenting service● Numerous web frameworks – django, Zope, webapp2, web.py, pyramid, flask
  • 5.
    Python in theIndustry Desktop● Games – Counterstrike, Civilization IV● Cinema 4D – Graphics● Dropbox● GUI frameworks – PyGTK, PyQT,
  • 6.
    Python in theIndustry Scientific Computing● NASA● Packages: Scipy, Numpy, Matplotlib,
  • 7.
    Python in theIndustry Mobile● Nokia Symbian Series 60● Android – Scripting Layer for Android● Blackberry● Kivy – cross-platform: iOS, Android, Linux, Windows, Mac
  • 8.
    Python Basics● The interpreter – Installation – Windows (set path)● Datatypes: int, str, float, lists, tuples, dictionaries● Basic I/O
  • 9.
    Python Basics● Variables – Dynamically-typed vs statically-typed >>> x = 1 >>>y = “hello” – Strongly-typed >>> x + y● Type function >>> type(x)● Integer vs float >>> z = 1.0
  • 10.
    Python BasicsOperator Operation+ Addition- Subtraction/ Division* Multiplication** Power% Modulus
  • 11.
    Python Basics● How will this be evaluated? >>>X = 1 + 2 – 3 ** 4 * ( 5+6)
  • 12.
    Python Basics● Operator Precedence rules Parenthesis Power Multiplication Addition Left-to-right
  • 13.
    Python Basics● Integer division >>> 4/2 >>> 5/2● Mixing integer and floats >>> 5/2.0● Casting between integer and floats >>> float(5) >>>int(5.0)
  • 14.
    Python Basics Strings – sequence of characters >>> s = “hello world”● Looking inside >>> s[0]● Concatenation >>> s = ”hello ” + “world”● Finding length >>> len(s)● Slicing >>> s = s[0:5]
  • 15.
    Python Basics Handy String functions● find >>> s.find('e')● Replace >>> n = s.replace('e', 'a' )● Make upper, lower >>> u = s.upper()
  • 16.
    Python Basics● Get the second word 'world' by slicing >>> “hello, world”[x:y]
  • 17.
    Python Basics Lists – collection of values● Declaring >>> l = list() >>> l = []● Can hold different types >>> l = [1, 'a', [2, 3], 4] >>> l[2]● Appending >>> l.append('an item') >>>del(l[2])
  • 18.
    Python Basics Lists – collection of values● Getting length >>> len(l)● Slicing >>> l[1:4]● Converting between strings and lists >>> strlist = “this is a string”.split('s') >>> “z”.join(strlist)
  • 19.
    Python Basics● Append an item to the list within the list >>> l = [1, 'a', [2, 3], 4] >>> l = [1, 'a', [2, 3, 5], 4]
  • 20.
    Python Basics● Handy functions Sum >>> sum([2, 3, 4]) Max >>> max([2, 3, 4]) Min >>> min([2, 3, 4])
  • 21.
    Python Basics Dictionaries – key, value pairs Associative array, hash table● Declaring >>> d = dict() >>> d = {}● Setting a value >>> d[“event”] = “bootcamp” >>> d = {“event” : “bootcamp” }● Getting a value >>> d[“event”]
  • 22.
    Python Basics Mutability● Mutable – can change – Lists, dictionary● Immutable – cannot change – Strings, tuples● Try set, del..
  • 23.
    Python Basics Casting – numbers and strings● Strings and numbers >>> int(“234”) >>> str(234)
  • 24.
    Python Basics● Importing modules >>> import math >>> math.sqrt(4) >>> from math import sqrt >>> sqrt(4)● dir() function >>> dir(math)
  • 25.
    Python Basics● Basic I/O >>> name = raw_input() >>> name = raw_input(“Name: “) Input numbers: >>>age = raw_input(“Age: “) >>>age = int(raw_input(“Age: “))
  • 26.
    Modules●Interactive mode vs modules● Indentation
  • 27.
    Boolean Values● True >>> 1 < 2● False >>> 1 > 2● Also evaluate to False: “”, [], {}, 0
  • 28.
    Loops●While loop – while condition is true x=0 while x < 10: print x x=x+1● For loop – loops over items words = ['this' , 'is', 'a', 'list'] for w in words: print w● Loop over strings, dictionaries..● Range() function >>> range(3) >>> range(0, 10, 2)
  • 29.
    Functions●Defining functions def say_hello(): print “hello”● Calling functions say_hello()● Parameters def sub(a, b): s=a-b return s sub(b=3, a=2)
  • 30.
    Functions●Commenting in Python def sub(a, b): d = a – b #subtracts b from a return d● Doc strings def sub(a, b): “””this functions takes in 2 integers and returns their difference””” d=a–b return d
  • 31.
    File I/O● Writing to a file f = open('text.txt', 'wb') f.write('This is a line.n') f.close()● Reading a file f = open('text.txt', 'rb') stream = f.read() f.close()
  • 32.
    Accessing the Web● Establishing a connection – sockets● Requests and Responses – GET, retrieve a webpage – POST, save data● Download a webpage fopen = urllib.urlopen(“http://www.google.com”) data = fopen.read()
  • 33.
    Demo●Web demo● Scientific computing
  • 34.
    Next Steps● Intermediate topics: – Classes and objects in Python – Regular Expressions – Exceptions etc● Python on Appengine● Python user group
  • 35.
    Resources●Official Python Docs tutorial http://docs.python.org/2/tutorial/● A byte of Python http://www.swaroopch.com/notes/python/● Think like a Computer Scientist http://www.openbookproject.net/thinkcs/python/english2e/

[8]ページ先頭

©2009-2025 Movatter.jp