Intro to
Programming
(with Python)

Fall 2019
course
site

Thu Sep 26

The assignment for Tuesday has been posted.

Questions about anything?

more lists, strings, files

Today we'll finish the material in chapter 5 in the text, covering strings, lists, and files.

Review from Tuesday

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".

in class

... we wrote the attached file_summary.py program as an example.

https://cs.marlboro.college /cours /fall2019 /python /notes /chap5b
last modified Tue December 3 2024 5:26 pm

attachments [paper clip]

  last modified size
TXT file_summary.py Tue Dec 03 2024 05:26 pm 830B