KEMBAR78
Week 8 intro to python | PPTX
Speaking in Code




Intro to Python




Brian Lee

Professor Liel Leibovitz
Speaking in Code


Logistics: Projects
• As open-ended as you want
• Due Date: Some time reasonable – end of semester
• Some ideas:
  – Choose your own adventure
  – Blog, Personal Site
• Requirements:
  – Decent amount of code
  – Please include comments
Speaking in Code


JavaScript

• Barely scratched the surface of JavaScript

• Resources:
   – http://www.codecademy.com/tracks/javascript

   – Any O’Reilly Books
      • http://bit.ly/good-parts

      • http://bit.ly/js-web-apps
Speaking in Code


Brief Intro: jQuery

• jQuery is not a language
   jQuery === JavaScript


• jQuery is a JavaScript library
   – A prepackaged, reusable set of functions and tools

• Makes it easier to manipulate webpages
Speaking in Code


Brief Intro: jQuery
Speaking in Code


Brief Intro: jQuery

<p>Just a normal p tag here</p>




$(“p”).addClass(“highlight”)




<p class=“highlight”>Just a normal p tag here</p>
Speaking in Code


Brief Intro: jQuery

• Resources:
  – http://learn.jquery.com/

  – http://www.codecademy.com/tracks/jquery
Speaking in Code


On to the Next!
• That’s it for web technologies!
Speaking in Code


Back to the Backend

• Frontend
  – Browsers

  – User directly interacts and sees this

• Backend
  – Server-side

  – Examples: validation -> creating user accounts
Speaking in Code


Conceptualizing the Backend

• Server handles the server-side languages
   – Ruby

   – Python

   – PHP

   – etc.
Speaking in Code


Why do we need server-side language?
Speaking in Code


Why do we need server-side language?
1. Browser: Give me this webpage! (typing in url)
2. Server: Okay, got your message!
3. Server: Runs server-side script that analyzes data
  –   Who is this user? What does this user have access to?

4. Server: Dynamically creates HTML file to send
5. Browser: Receives HTML file (which includes HTML,
   CSS, JavaScript, etc)
Speaking in Code


What do servers do?

• Processes data before it shows on the browser

• Central location to store data

• Server-side scripts process and analyze the data
   – Data manipulation

• Servers are essentially very powerful computers
Speaking in Code


Sever-side Scripts vs JavaScript

• Cannot see the server side source code

• Inspect Element shows you all “resources” that live in
  the client-side
   – HTML, CSS, JavaScript
Speaking in Code


Intro to Python

• Programming language that is widely used

• LOTS of companies use it:
   – http://b.qr.ae/XvvkWV

• Simpler and more intuitive syntax (more like English)
Speaking in Code


Intro to Python: Variables

• Same as JavaScript, except simpler syntax

• Python:

name = ‘Brian’

• JavaScript
var name = ‘Brian’;`
Speaking in Code


Intro to Python: Data Types

• Remember this in JavaScript?

• Booleans: True or False

• Numbers

• Strings: “hello”, ‘1’
Speaking in Code


Intro to Python: Data Types

• Remember this in JavaScript?

• Booleans: True or False
   – Must be Capitalized

• Numbers

• Strings: “hello”, ‘1’
Speaking in Code


Intro to Python: Data Types

• Remember this in JavaScript?

• Booleans: True or False

• Numbers
   – Integer: 1, 2, -2331, -4

   – Floats: 1.0, 12.321321

• Strings: “hello”, ‘1’
Speaking in Code


Intro to Python: Data Types

• Remember this in JavaScript?

• Booleans: True or False

• Numbers

• Strings: “hello”, ‘1’
   – Double or Single quotes
Speaking in Code


Intro to Python: Syntax

• No more worrying about JavaScript syntax
   –{ }

   –;

   – var

• Each line is interpreted as a statement
Speaking in Code


Intro to Python: Syntax – Whitespace

• Indentation and white space matter!

• Whitespace is same as “;” in JavaScript

number = 12
if number < 5:
     print “Dang”
     print “Less than 5?”
print “hello”
Speaking in Code


Intro to Python: Comments

• Yes comments exist here as well!

• Single line comments:
# Guess there isn’t much to say…


• Multi-line comments: Triple Quotes

‘’’Can exist
in multiple
lines’’’
Speaking in Code


Try it out:

http://bit.ly/nyupython
Speaking in Code


Easter Egg

• Zen of Python


import this

Week 8 intro to python

  • 1.
    Speaking in Code Introto Python Brian Lee Professor Liel Leibovitz
  • 2.
    Speaking in Code Logistics:Projects • As open-ended as you want • Due Date: Some time reasonable – end of semester • Some ideas: – Choose your own adventure – Blog, Personal Site • Requirements: – Decent amount of code – Please include comments
  • 3.
    Speaking in Code JavaScript •Barely scratched the surface of JavaScript • Resources: – http://www.codecademy.com/tracks/javascript – Any O’Reilly Books • http://bit.ly/good-parts • http://bit.ly/js-web-apps
  • 4.
    Speaking in Code BriefIntro: jQuery • jQuery is not a language jQuery === JavaScript • jQuery is a JavaScript library – A prepackaged, reusable set of functions and tools • Makes it easier to manipulate webpages
  • 5.
  • 6.
    Speaking in Code BriefIntro: jQuery <p>Just a normal p tag here</p> $(“p”).addClass(“highlight”) <p class=“highlight”>Just a normal p tag here</p>
  • 7.
    Speaking in Code BriefIntro: jQuery • Resources: – http://learn.jquery.com/ – http://www.codecademy.com/tracks/jquery
  • 8.
    Speaking in Code Onto the Next! • That’s it for web technologies!
  • 9.
    Speaking in Code Backto the Backend • Frontend – Browsers – User directly interacts and sees this • Backend – Server-side – Examples: validation -> creating user accounts
  • 10.
    Speaking in Code Conceptualizingthe Backend • Server handles the server-side languages – Ruby – Python – PHP – etc.
  • 11.
    Speaking in Code Whydo we need server-side language?
  • 12.
    Speaking in Code Whydo we need server-side language? 1. Browser: Give me this webpage! (typing in url) 2. Server: Okay, got your message! 3. Server: Runs server-side script that analyzes data – Who is this user? What does this user have access to? 4. Server: Dynamically creates HTML file to send 5. Browser: Receives HTML file (which includes HTML, CSS, JavaScript, etc)
  • 13.
    Speaking in Code Whatdo servers do? • Processes data before it shows on the browser • Central location to store data • Server-side scripts process and analyze the data – Data manipulation • Servers are essentially very powerful computers
  • 14.
    Speaking in Code Sever-sideScripts vs JavaScript • Cannot see the server side source code • Inspect Element shows you all “resources” that live in the client-side – HTML, CSS, JavaScript
  • 15.
    Speaking in Code Introto Python • Programming language that is widely used • LOTS of companies use it: – http://b.qr.ae/XvvkWV • Simpler and more intuitive syntax (more like English)
  • 16.
    Speaking in Code Introto Python: Variables • Same as JavaScript, except simpler syntax • Python: name = ‘Brian’ • JavaScript var name = ‘Brian’;`
  • 17.
    Speaking in Code Introto Python: Data Types • Remember this in JavaScript? • Booleans: True or False • Numbers • Strings: “hello”, ‘1’
  • 18.
    Speaking in Code Introto Python: Data Types • Remember this in JavaScript? • Booleans: True or False – Must be Capitalized • Numbers • Strings: “hello”, ‘1’
  • 19.
    Speaking in Code Introto Python: Data Types • Remember this in JavaScript? • Booleans: True or False • Numbers – Integer: 1, 2, -2331, -4 – Floats: 1.0, 12.321321 • Strings: “hello”, ‘1’
  • 20.
    Speaking in Code Introto Python: Data Types • Remember this in JavaScript? • Booleans: True or False • Numbers • Strings: “hello”, ‘1’ – Double or Single quotes
  • 21.
    Speaking in Code Introto Python: Syntax • No more worrying about JavaScript syntax –{ } –; – var • Each line is interpreted as a statement
  • 22.
    Speaking in Code Introto Python: Syntax – Whitespace • Indentation and white space matter! • Whitespace is same as “;” in JavaScript number = 12 if number < 5: print “Dang” print “Less than 5?” print “hello”
  • 23.
    Speaking in Code Introto Python: Comments • Yes comments exist here as well! • Single line comments: # Guess there isn’t much to say… • Multi-line comments: Triple Quotes ‘’’Can exist in multiple lines’’’
  • 24.
    Speaking in Code Tryit out: http://bit.ly/nyupython
  • 25.
    Speaking in Code EasterEgg • Zen of Python import this

Editor's Notes

  • #4 Go to the track check out some projects
  • #8 $(&apos;.title:first&apos;).html(&apos;what kind of sorcery is this&apos;)
  • #11 Facebook server room
  • #14 What are you going to do with data you receive, ie from a form,