The assignment for Tuesday has been posted.
Questions about anything?
Today we'll finish the material in chapter 5 in the text, covering strings, lists, and files.
Review from Tuesday
'abcde'[2]
, 'abcdefghi'[3:7]
list("one two three")
"one two three".split()
str(['a', 'b', 'c])
''.join(['a', 'b', 'c'])
What's left to talk about
We'll work through some examples or two in class.
A certain CS professor gives 5-point quizzes that are graded on the scale
5-A, 4-B, 3-C, 2-D, 1-F, 0-F. Write a program that accepts a quiz score
as an input and prints out the corresponding grade.
write a program that reads in a file of numbers with
commas between them, and writes a summary with lines 'count:_'
and 'average:_'.
rewrite the chaos program from chapter 1 in several ways :
(a) print the numbers in a nicely aligned table
(b) output the numbers to a file
(c) read the inputs from a file
Translate a lowercase word into its cipher, with each letter incremented by 1 - encoding.
Write another program that translates it back - decoding.
Aside: unix command line input/output redirection as an alternative way to do file input output
$ python yourprogram.py < input.txt > output.txt
Aside: running python: "python mything.py" vs "import mything".
... we wrote the attached file_summary.py program as an example.
last modified | size | ||
file_summary.py | Fri Dec 13 2024 08:16 am | 830B |