CSci 150: Foundations of computer science
Home Syllabus Readings Projects Tests

printable version

Bonus Quiz

[1] [2]

Problem BQ.1.

[8 pts] Suppose the file pops.txt contains a series of lines, each containing three tab-separated values: a city name, a state name, the city's current population, and the city's population three years ago. Here are five example lines from the file.

Chicago        Illinois        9899902      9840929
Los Angeles    California      18238998     17877006
New York       New York        23362099     23076664
San Francisco  California      8370967      8153696
Washington     DC              9331587      9051961

Complete the below program to display the name of each city with a current population exceeding 5,000,000. (The order in which the names appear does not matter.)

infile = open('pops.txt')
for line in infile: