Upload
brianjihoonlee
View
84
Download
1
Tags:
Embed Size (px)
Citation preview
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 is a JavaScript library
– A prepackaged, reusable set of functions and tools
• Makes it easier to manipulate webpages
jQuery === JavaScript
Speaking in Code
Brief Intro: jQuery
Speaking in Code
Brief Intro: jQuery
$(“p”).addClass(“highlight”)
<p>Just a normal p tag here</p>
<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:
• JavaScript
name = ‘Brian’
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 = 12if 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:
• Multi-line comments: Triple Quotes
# Guess there isn’t much to say…
‘’’Can existin multiplelines’’’
Speaking in Code
Easter Egg
import this
• Zen of Python