Aug 28: Formatted Strings; Math: Division and Modulo
Learning Objectives
After today's class, you should be able to:
- Explain differences between integer and floating-point numbers.
- Write an f-string with multiple expressions and format specifiers.
- Evaluate mathematical expressions similar to a calculator.
- Identify and justify the precedence of arithmetic operators.
- Describe the function of Python's three division operators.
Lesson Outline¶
Hoemework Debrief
Are you tired of getting emails from Gradescope?
- See instructions on shared website
Some highlights:
- Inputting an integer:
int(input())
- Escape sequences:
\t
,\"
,\\
- Separate calculations and output
Options at the end of print()
:
sep=
separator (default: space)end=
ending (default: newline)
F-strings
Example programs
welcome.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 |
|
Example format specifiers (after the colon):
numbers.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Mini Lecture
POGIL Activity
- Arithmetic Expressions
- If you are absent today, complete this activity at home
- Bring your completed activity to class or office hours
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 might see next week.
Your To-Do List¶
-
Due Friday
- Survey on Canvas
-
Due Tuesday Sept 2nd by 3pm
- Complete week 2 readings and activities
-
Due Wednesday Sept 3rd by 11:00pm
- Complete and submit HW 2 – ideally:
- 1 and 2 before Friday
- 3 and 4 before Tuesday
- Recall you need to go through Canvas to submit all parts of the homework
- Complete and submit HW 2 – ideally: