SlideShare a Scribd company logo
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

More Related Content

PPT
Coldfusion
 
DOC
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PPTX
Week 4 css recap and js
PDF
Metaprogramming Go
PDF
Fast Web Applications with Go
PPTX
php basic part one
PDF
Scala.io
KEY
php app development 1
Coldfusion
 
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
Week 4 css recap and js
Metaprogramming Go
Fast Web Applications with Go
php basic part one
Scala.io
php app development 1

What's hot (17)

PDF
Making CLI app in ruby
PPTX
Functional Programming in PHP
PDF
NLP using JavaScript Natural Library
PPT
WorkinOnTheRailsRoad
PPT
Workin ontherailsroad
PPT
01 basics
PPT
php basic
ODP
Glance rebol
PDF
Module-3 15CS71-WTA-Serverside Development with PHP
PDF
The Spoofax Language Workbench (SPLASH 2010)
PDF
Create Your Own Language
KEY
Future of PHP
PDF
LIL Presentation
PPTX
Programming Paradigm & Languages
PDF
Unknown features of PHP
PPTX
Building Your Own DSL with Xtext
Making CLI app in ruby
Functional Programming in PHP
NLP using JavaScript Natural Library
WorkinOnTheRailsRoad
Workin ontherailsroad
01 basics
php basic
Glance rebol
Module-3 15CS71-WTA-Serverside Development with PHP
The Spoofax Language Workbench (SPLASH 2010)
Create Your Own Language
Future of PHP
LIL Presentation
Programming Paradigm & Languages
Unknown features of PHP
Building Your Own DSL with Xtext
Ad

Similar to Week 8 intro to python (20)

PPTX
Hello World - Introduction to coding.pptx
PPTX
Week 5
PPTX
Week 5
PPTX
Week 1 - Intro to the Internet
PPTX
Week 5 java script functions
PDF
Intro to Python Workshop San Diego, CA (January 19, 2013)
PPTX
UVA MDST 3703 JavaScript (ii) 2012-10-04
PDF
Client side scripting
PPTX
Introduction to Coding
PPT
Introduction to JavaScript
PPTX
What Is Coding And Why Should You Learn It?
PPTX
Introduction to Coding in simple terms to
PDF
Training javascript 2012 hcmut
PPTX
JEAA Workshop - Programming for Communicators
PDF
Intro to JavaScript
PDF
Fewd week4 slides
PDF
Tutor Py
PPTX
Lesson 301 26 nov13-1500-ay
PDF
What is Python? (Silicon Valley CodeCamp 2014)
PDF
Introduction to Javascript programming
Hello World - Introduction to coding.pptx
Week 5
Week 5
Week 1 - Intro to the Internet
Week 5 java script functions
Intro to Python Workshop San Diego, CA (January 19, 2013)
UVA MDST 3703 JavaScript (ii) 2012-10-04
Client side scripting
Introduction to Coding
Introduction to JavaScript
What Is Coding And Why Should You Learn It?
Introduction to Coding in simple terms to
Training javascript 2012 hcmut
JEAA Workshop - Programming for Communicators
Intro to JavaScript
Fewd week4 slides
Tutor Py
Lesson 301 26 nov13-1500-ay
What is Python? (Silicon Valley CodeCamp 2014)
Introduction to Javascript programming
Ad

Week 8 intro to python

  • 1. Speaking in Code Intro to 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 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
  • 5. Speaking in Code Brief Intro: jQuery
  • 6. 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>
  • 7. Speaking in Code Brief Intro: jQuery • Resources: – http://learn.jquery.com/ – http://www.codecademy.com/tracks/jquery
  • 8. Speaking in Code On to the Next! • That’s it for web technologies!
  • 9. Speaking in Code Back to the Backend • Frontend – Browsers – User directly interacts and sees this • Backend – Server-side – Examples: validation -> creating user accounts
  • 10. Speaking in Code Conceptualizing the Backend • Server handles the server-side languages – Ruby – Python – PHP – etc.
  • 11. Speaking in Code Why do we need server-side language?
  • 12. 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)
  • 13. 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
  • 14. 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
  • 15. 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)
  • 16. Speaking in Code Intro to Python: Variables • Same as JavaScript, except simpler syntax • Python: name = ‘Brian’ • JavaScript var name = ‘Brian’;`
  • 17. Speaking in Code Intro to Python: Data Types • Remember this in JavaScript? • Booleans: True or False • Numbers • Strings: “hello”, ‘1’
  • 18. Speaking in Code Intro to Python: Data Types • Remember this in JavaScript? • Booleans: True or False – Must be Capitalized • Numbers • Strings: “hello”, ‘1’
  • 19. 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’
  • 20. Speaking in Code Intro to Python: Data Types • Remember this in JavaScript? • Booleans: True or False • Numbers • Strings: “hello”, ‘1’ – Double or Single quotes
  • 21. Speaking in Code Intro to Python: Syntax • No more worrying about JavaScript syntax –{ } –; – var • Each line is interpreted as a statement
  • 22. 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”
  • 23. 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’’’
  • 24. Speaking in Code Try it out: http://bit.ly/nyupython
  • 25. Speaking in Code Easter Egg • 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,