In this exercise, you practice with functions and file I/O.
Exercise 1: Write a function that converts from Fahrenheit zu Celsius and returns the result (e.g., see Temperature Conversion). Embed your function in a larger program that tells the user what the program is for and asks the uer to input a certain number that can be converted. Allow for the program to loop, so that the user can input numbers over and over again until they choose to exit the program.
Exercise 2: Work through Zacharski's sentence generator in Chapter 2, section 2.5 (pp. 42-45).
execfile("sentence_generator.py") |
and then proceed as described in the chapter. In Python 3.X, it is harder to execute files from within the interpreter (especially with functions in them). Alternatively, if you want to stick with Python 3.X, you can use this version of the program.
Exercise 3: Work through Zacharski's section 3.3.1 in Chapter 3 on string replace. Now take the text hexe.txt and
Please send the programs for all of the exercises to aikaterini-lida at uni konstanz by 11:30 am on December 12th, 2014.