week 8 intro to python
TRANSCRIPT
![Page 1: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/1.jpg)
Speaking in Code
Intro to Python
Brian Lee
Professor Liel Leibovitz
![Page 2: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/2.jpg)
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
![Page 3: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/3.jpg)
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
![Page 4: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/4.jpg)
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
![Page 5: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/5.jpg)
Speaking in Code
Brief Intro: jQuery
![Page 6: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/6.jpg)
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>
![Page 7: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/7.jpg)
Speaking in Code
Brief Intro: jQuery
• Resources:
– http://learn.jquery.com/
– http://www.codecademy.com/tracks/jquery
![Page 8: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/8.jpg)
Speaking in Code
On to the Next!
• That’s it for web technologies!
![Page 9: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/9.jpg)
Speaking in Code
Back to the Backend
• Frontend
– Browsers
– User directly interacts and sees this
• Backend
– Server-side
– Examples: validation -> creating user accounts
![Page 10: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/10.jpg)
Speaking in Code
Conceptualizing the Backend
• Server handles the server-side languages
– Ruby
– Python
– PHP
– etc.
![Page 11: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/11.jpg)
Speaking in Code
Why do we need server-side language?
![Page 12: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/12.jpg)
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)
![Page 13: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/13.jpg)
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
![Page 14: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/14.jpg)
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
![Page 15: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/15.jpg)
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)
![Page 16: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/16.jpg)
Speaking in Code
Intro to Python: Variables
• Same as JavaScript, except simpler syntax
• Python:
• JavaScript
name = ‘Brian’
var name = ‘Brian’;`
![Page 17: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/17.jpg)
Speaking in Code
Intro to Python: Data Types
• Remember this in JavaScript?
• Booleans: True or False
• Numbers
• Strings: “hello”, ‘1’
![Page 18: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/18.jpg)
Speaking in Code
Intro to Python: Data Types
• Remember this in JavaScript?
• Booleans: True or False
– Must be Capitalized
• Numbers
• Strings: “hello”, ‘1’
![Page 19: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/19.jpg)
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’
![Page 20: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/20.jpg)
Speaking in Code
Intro to Python: Data Types
• Remember this in JavaScript?
• Booleans: True or False
• Numbers
• Strings: “hello”, ‘1’
– Double or Single quotes
![Page 21: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/21.jpg)
Speaking in Code
Intro to Python: Syntax
• No more worrying about JavaScript syntax
– { }
– ;
– var
• Each line is interpreted as a statement
![Page 22: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/22.jpg)
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”
![Page 23: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/23.jpg)
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’’’
![Page 25: Week 8 intro to python](https://reader033.vdocuments.mx/reader033/viewer/2022052411/5565ea42d8b42a20638b4c23/html5/thumbnails/25.jpg)
Speaking in Code
Easter Egg
import this
• Zen of Python