Last class you learned about the difference between the Python Shell and the Python Editor. You also started a little bit on variables.
Today you’ll be using the Python Shell to learn about calculations and using variables in those calculations.
Using the shell as a calculator.
- Calculate 5.5 x 8.34
- Use the star symbol for multiplication.
- It should look something like this or this
- Using spaces or not, do you get the same answer?
All of these can be accessed from the keypad on the far right of your keyboard.
Slide 5: Order of Operations
Try the following math problem. 5+10 * 3
- What is the answer?
- What is the order of operations?
- How would you change it to add first, then multiply?
Slide 6: The Answer
Python does its order of operations just like in math class.
Slide 7: Variables
A variable is a place to store information. I can store the number 16 into the variable called ‘steve’
Then I can redefine ‘steve’ on the next line to be 17.
I can set variables equal to variables.
Slide 8: Using Variables in Math
I can use a variable in a math problem. Don’t forget, it will still follow the order of operations.
Slide 9: Write a code for this problem
Jack was twice as old as his 13 year old brother, and 7 years older than his sister. How old is Jack’s sister?
Hint: You need 3 variables and a print.
Slide 11: Assignment
- William Casey Radcliffe is half his mother’s age. His mother is 200 years younger than the United States of America. How old is Will?
- The Distance to the moon is about 10 times the circumference of the Earth. The distance to the sun is about 4000 times farther. If the sun is 96,000,000 miles away, what’s the circumference of the Earth?
- Andre is five-sixths the height of LeBron James who is two-thirds the height of a regulation basketball hoop. How tall is Andre?
- In the summer of 2010 I pulled out a concrete patio. The patio was 12 square feet. If the volume of the patio was 48 feet cubed, what was its depth?
- OPS is a baseball statistic which is the sum of OBP (on base percentage) and SLG (slugging percentage). If Jose Ramirez’s OBs is .825, and his SLG is .462, what’s his OPB?