Intro to PythonIntro to Python
April 2018
Wi : MakeOf ces 5Ghz
Password: Internet!23
http://bit.lyhttp://bit.ly/python-intro-dc/python-intro-dc
1
Instructor
TJ Stalcup
Lead Mentor @Thinkful (3yr)
SE Lead @540
Developer (22y)
Pokemon Master
TAshttp://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Matthew Gifford
Instructional Designer
Mastering Web Dev
Voice of the Gods
npm start
2
About you
What's your name? 
What brought you here today?
What is your programming experience?
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest
3
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
About Thinkful
Thinkful helps people become developers and data scientists
through 1-on-1 mentorship and project-based learning
These workshops are built using this approach.
4
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Take advantage of our support
Don't get discouraged, struggle leads to mastery
Don't be shy, take full advantage of our support
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 5
Agenda
Learn key Python concepts (30 min)
Go over assignments (10 min)
Complete assignments with our support! (30 min)
Go over answer key (10 min)
Steps to continue learning (10 min)
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 6
How the web works
Type a URL from a client (e.g. google.com)
Browser sends an HTTP request asking for speci c les
Browser receives those les and renders them as a website
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 7
Client/Servers
Client (sends requests)
Frontend Developer
Manages what user sees
Server (sends response)
Backend Developer
Manages what app does
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc
8
bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Example: facebook.com
Client Server
Open browser
and navigate to
facebook.com
HTML, CSS, &
Javascript render
newsfeed
Request
Response
Algorithm
determines
content of feed.
(Python, PHP,
Java, .NET, Ruby,
etc)
 
Sends back
HTML, CSS,
Javascript les
Application Logic
Initial request
Following response
We'll be writing Python, the code that
the browser uses to run the app
9
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
History of Python
Written in the late 1980s 
Emphasis on code readability
Uses whitespace to structure code, instead of syntax
Has nothing to do with Monty Python, but.....
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 10
Why Python?
Easy to learn for beginners (Middle-High School)
General Language (Server-Side, Robotics, Data Science,
Automation, etc.)
High Demand - 12.7% of the job market (#2 Programming
Language)
Ssssssssssssss
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 11
Real developers use Google... a lot
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 12
De ning a variable
numberOfSheep = 20numberOfSheep = 20
Name of variable
Value of variable
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 13
Variable examples
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz
Password: Internet!23
14bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Repl.it
Register
My repls
Plus -> All Languages
Search Python, Select First
Declaring a function
def greeting():def greeting():
   return"Hello world!"   return"Hello world!"
Initialize function Name of function
What the function does
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc
15
bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Parameters within functions
def adder(a,b):def adder(a,b):
   return a + b   return a + b
  
adder(1,2)adder(1,2)
Parameters in declaration
Parameters used
within the function
bit.ly/ js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23 bit.ly/js-intro-dcWiFi: In3Guest
16
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Examples of parameters within functions
bit.ly/ js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23 17bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
Repl.it setup & rst steps!
tf-python-challengeshttp://bit.ly/
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 18
if/else Statements
go to gas stationkeep driving
if false if true
need gas?
family roadtrip
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23 19
Comparing Values
==    (equal to)
 
         5 == 5  --> true
         5 == 6  --> false
 
!=     (not equal to)
 
         5 != 5  --> false
         5 != 6  --> true
 
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc
20
bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
if/else Statements
def familyRoadtrip():
    if needGas == true:
        getGas()
    else:
        keepDriving()
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc
21
bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
http://bit.ly/js-intro-dc
WiFi: MakeOf ces 5Ghz / Internet!23
if/else Statements 
bit.ly/ js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dcWiFi: In3Guest
bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
22
bit.ly/js-intro-dc bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: IN3Guest
bit.ly/js-intro-dcWiFi: In3Guest
bit.ly/js-intro-dc
Exercise Solutions
bit.ly/ js-intro-dcWiFi: MakeOf ces 5Ghz
Password: Internet!23
bit.ly/js-intro-dc
tf-python-challengeshttp://bit.ly/
23

Intro to Python

  • 1.
    Intro to PythonIntroto Python April 2018 Wi : MakeOf ces 5Ghz Password: Internet!23 http://bit.lyhttp://bit.ly/python-intro-dc/python-intro-dc 1
  • 2.
    Instructor TJ Stalcup Lead Mentor@Thinkful (3yr) SE Lead @540 Developer (22y) Pokemon Master TAshttp://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 Matthew Gifford Instructional Designer Mastering Web Dev Voice of the Gods npm start 2
  • 3.
    About you What's yourname?  What brought you here today? What is your programming experience? bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest 3 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 4.
    About Thinkful Thinkful helpspeople become developers and data scientists through 1-on-1 mentorship and project-based learning These workshops are built using this approach. 4 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 5.
    Take advantage ofour support Don't get discouraged, struggle leads to mastery Don't be shy, take full advantage of our support http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 5
  • 6.
    Agenda Learn key Pythonconcepts (30 min) Go over assignments (10 min) Complete assignments with our support! (30 min) Go over answer key (10 min) Steps to continue learning (10 min) http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 6
  • 7.
    How the webworks Type a URL from a client (e.g. google.com) Browser sends an HTTP request asking for speci c les Browser receives those les and renders them as a website bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 7
  • 8.
    Client/Servers Client (sends requests) FrontendDeveloper Manages what user sees Server (sends response) Backend Developer Manages what app does bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc 8 bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 9.
    Example: facebook.com Client Server Openbrowser and navigate to facebook.com HTML, CSS, & Javascript render newsfeed Request Response Algorithm determines content of feed. (Python, PHP, Java, .NET, Ruby, etc)   Sends back HTML, CSS, Javascript les Application Logic Initial request Following response We'll be writing Python, the code that the browser uses to run the app 9 bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 10.
    History of Python Writtenin the late 1980s  Emphasis on code readability Uses whitespace to structure code, instead of syntax Has nothing to do with Monty Python, but..... bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 10
  • 11.
    Why Python? Easy tolearn for beginners (Middle-High School) General Language (Server-Side, Robotics, Data Science, Automation, etc.) High Demand - 12.7% of the job market (#2 Programming Language) Ssssssssssssss bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 11
  • 12.
    Real developers useGoogle... a lot bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 12
  • 13.
    De ning avariable numberOfSheep = 20numberOfSheep = 20 Name of variable Value of variable bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 13
  • 14.
    Variable examples bit.ly/js-intro-dcWiFi: MakeOfces 5Ghz Password: Internet!23 bit.ly/js-intro-dc bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz Password: Internet!23 14bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 Repl.it Register My repls Plus -> All Languages Search Python, Select First
  • 15.
    Declaring a function defgreeting():def greeting():    return"Hello world!"   return"Hello world!" Initialize function Name of function What the function does bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc 15 bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 16.
    Parameters within functions defadder(a,b):def adder(a,b):    return a + b   return a + b    adder(1,2)adder(1,2) Parameters in declaration Parameters used within the function bit.ly/ js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: In3Guest 16 bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 17.
    Examples of parameterswithin functions bit.ly/ js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 17bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 18.
    Repl.it setup &rst steps! tf-python-challengeshttp://bit.ly/ bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 18
  • 19.
    if/else Statements go togas stationkeep driving if false if true need gas? family roadtrip bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23 19
  • 20.
    Comparing Values ==   (equal to)            5 == 5  --> true          5 == 6  --> false   !=     (not equal to)            5 != 5  --> false          5 != 6  --> true   bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc 20 bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 21.
    if/else Statements def familyRoadtrip():    if needGas == true:         getGas()     else:         keepDriving() bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc 21 bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest http://bit.ly/js-intro-dc WiFi: MakeOf ces 5Ghz / Internet!23
  • 22.
    if/else Statements  bit.ly/ js-intro-dcWiFi:MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: In3Guest bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 22 bit.ly/js-intro-dc bit.ly/js-intro-dcWiFi: MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: IN3Guest bit.ly/js-intro-dcWiFi: In3Guest bit.ly/js-intro-dc
  • 23.
    Exercise Solutions bit.ly/ js-intro-dcWiFi:MakeOf ces 5Ghz Password: Internet!23 bit.ly/js-intro-dc tf-python-challengeshttp://bit.ly/ 23