September 05: Expressions
Learning Objectives
After today's class, you should be able to:
- Describe the function of Python's three division operators.
- Identify in code: functions, operators, expressions, and statements.
- Determine the value and type of arithmetic expressions (on paper).
- Solve problems using real division, floor division, and remainder.
Lesson Outline¶
Practice Quiz
- Log in as student
- Open thonny and a web browser
- Log into canvas and gradescope
- Docstring and PEP 8 not required
- Practice quiz
Team Work
- Python Terminology
- Discuss and answer these questions with a group size of 2 to 3
- If you are absent today, complete this sheet at home
Mini Lecture
- Chapter 2: Ch 2
- Expressions
Class Activity
Practice Problem 1: Miles, Furlongs, and Feet
Write a program called feet_conversion.py
that inputs a total number
of feet and divide that number into miles, furlongs, and feet.
(A furlong is some old English measure nobody uses anymore, but let's do it anyway!)
1 mile is 5280 feet, and 1 furlong is 660 feet.
Here is an example run of the program:
Enter a total number of feet: 12345 12345 total feet is 2 mile(s), 2 furlong(s), and 465 feet.
Hint 1: Figure out how to solve the problem yourself by hand on paper. You can't code something you don't know how to solve.
Hint 2: You will need to use floor division and remainder (//
and %
).
Hint 3: Create a variable for the remaining feet. In the example above, the remaining feet is initially 12345. Once you figure out there are two full miles in 12345 feet (2 full miles is 10560 feet), then the remaining feet is 1785. How many full furlongs are in 1785 feet? Well, 2 again, since \(660\times2 = 1320\). And finally after we remove those 1320 from 1785, the remaining feet is 465.
Helpful Video¶
Please watch this 10-minute video recorded by Dr. Sprague in Spring 2022. The video explains how to interpret the (often confusing) feedback on Gradescope. The video also walks through an in-class exercise that you have seen.
Interpreting Gradescope Feedback
Your To-Do List¶
Due Wednesday September 6th at 11pm
Prepare for Quiz 1A
- Thursday, beginning of class, 25 minutes, in EnGeo 2204.
- Two parts: concepts and programming (will use lab machine account, canvas and gradescope)
- Study chapters 1 and 2: both reading and activities
- Review class activities
- Review homework programming assignments