Previous Lecture | Lecture 8 | Next Lecture |
Lecture 8, Wed 08/22
files, more loops
Code from class
https://github.com/ucsb-cs8-m18/code-from-class/tree/master/08-22
Midterm notes must be handwritten!
If you turn in your HW through Gradescope, you don’t have to turn it in in class.
iClicker Questions
0. Which while loop implements the same functionality as the following for loop?
for i in range(5):
print(i)
(a) i = 1
while i <= 5:
print(i)
i += 1
(b) i = 1
while i < 5:
print(i)
i += 1
(c) i = 0
while i < 5:
print(i)
i += 1
(d) i = 0
while i <= 5:
print(i)
i += 1
(e) None of the above
In-Class Questions / Schedule of Events
- File open, mode, read, readlines, close, write (see book)
- Shakespeare word count (import the word count file)
- Break, continue, pass
- Guess the number game
- Accumulator pattern
- List sum, list product, compute factorial
- Global variables https://stackoverflow.com/questions/423379/using-global-variables-in-a-function