* SDA intros
* Questions
* Get to know you activity
V Refresh
* arithmetic operators
* variable name on left side vs right side
V to make variable names easier to read, convention is to use underscores or capitalization
* cur_temp or curTemp
* the former is called snake case and the latter is called camel case
V what might make for a good variable name?
* not too long
* describes what the variable represents
V Problem: what icon to display in weather app?
V Simplified problem: difference between current and “hot” temperature (i.e., should the app show the current temperature in red)
V calculate difference
* difference = hot_temp - cur_temp_F
* make a diagram of memory after each step (line of code)
V diagram the following steps
V x = 10
y = x
x = x + 5
* y and x label separate locations in memory, the second step copies the value stored as x to a new location and labels it y
* so the third line overwrites the value for x, but not for y
V [NOW ON SCREEN] output result (three mistakes: missing “, missing ), typo in variable name)
* Forgetting a close “ around text causes a SyntaxError
V anatomy of the error message
* File where the error occurred, line where the error occurred, and the error type and message
* it may feel like it’s Python yelling at you for your mistakes
* really Python catching on fire and saying “I don’t understand, aaaaaaaahhhhhhhhhh.”
V how would you demonstrate to me this is correct (or incorrect)
* print everything, check for known results
V compare to one-line version
* print(“difference between hot and current temp in Celsius:”, (80 - 32) / 9 * 5 - get_cur_temp())
V comments
* any line that starts with a # is a comment
* ignored by Python, useful for explaining and documenting your code
V Python Standard Library
* https://docs.python.org/3/library/index.html
* Made up of modules which are made available by importing them
V example
* import math
print(math.sqrt(100)) # prints 10
print(math.sqrt(-100)) # causes ValueError since sqrt doesn’t know how to handle negative numbers
* Note how we access sqrt by writing <module name>.sqrt, this is how modules work in general
V Variation on import
* from math import sqrt
* lets us just write sqrt instead of math.sqrt