Sep 25: Quiz2, while loops and random
Learning Objectives
After today's class, you should be able to:
- Identify the three main components of a
while
loop - Use the
random
module to generate random numbers
Reminders¶
- Read Week 6 Reading and Activities – ideally:
- 1st half before Friday
- 2nd half before Monday
- Submit HW 6 – ideally:
- 1 and 2 before Friday
- 3 and 4 before Monday
HW5 Debrief¶
- Identity vs equality (
is
vs==
) - Helper functions (Ex:
swap()
) - Passing containers to functions
- If immutable, return new object
- If mutable, edit existing object
- Returning "fairness" of two sets
The Unofficial Graduation Requirement for CS/IT Majors
Students who write code like this will not be allowed to graduate:
if condition:
return True
else:
return False
The above code should be written without using an if
statement:
return condition
Quiz 2¶
- Two portions to the quiz: written and coding
- Log in as
student
- Start exam recording
- Log in to Canvas only
- Raise your hand when complete with Canvas written portion
- Open Thonny for coding portion only
- Submit code through Canvas (will go to Gradescope)
- Log out when finished
POGIL Activity¶
- While Loops
- If you are absent today, complete this activity at home
- Bring your completed activity to class or office hours
Example Code¶
Model 1
i = 0
while i < 3:
print("the number is", i)
i = i + 1
print("goodbye")
Question 9
total_count.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 |
|