## Homework 7 (Python 2) -- due Dec. 10

30 Nov 2011
1. Write a program that, given a filename on the command line, prints each line of the file preceded by the line number.

2. Write a "guess the number" program that chooses a random number in the range from 1 to 100, and then has you guess a number until you find the chosen value. After each guess it should tell you if you're too high or too low.

One way to write the program involves a new kind of loop, a while loop, that repeats the body until some condition fails. Using this loop, an outline of your program would look like:

import random

target = random.randint(1, 100)
guess = -1  # initialize to something wrong

while guess != target:  # this repeats the body until you guess right
guess = ... (read the guessed number and convert to an int)
if ... (test to see if it's too high or too low)

# if you make it past the loop, you've guessed right.
print('Good guess!')