Sep 04: Prac1, if-else Statements
Learning Objectives
After today's class, you should be able to:
- Explain the logistics for taking a quiz in CS 149.
- Describe the behavior of
if
,elif
, andelse
.
Reminders¶
- Due TODAY
- TeamPref on Canvas
- Tip: Look at 1Pic1Par
- HW2 Reflection on Canvas
- Upcoming events
- Read Ch 3 – ideally:
- 1st half before Friday
- 2nd half before Monday
- Submit HW 3 – ideally:
- 1 and 2 before Friday
- 3 and 4 before Monday
HW2 Debrief¶
[10 min]
Some highlights:
- Splitting up long lines of code
- Rounding to n decimal places
- Using
math
module functions //
and%
usually go together
Practice Quiz 1¶
[25 min]
Instructions:
- Log in as
student
- Only two windows:
- Thonny
- Web browser
- Web traffic monitored
- Log out when finished
Ch03 Preview¶
[15 min]
- Keywords:
if
,elif
("else if"),else
==
is a comparison operator ("is equal to")=
is the assignment operator ("is now")
- Indented blocks show the program structure
- The line before always ends with a colon
- Demo: Stepping over code with the debugger
- Go to Tools > Options… > Run & Debug
- Change preferred debugger to "faster"
fractions.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 |
|