Python Lesson 5 Exercises: Pre Made Functions
In the following exercise, pay attention to your user interface, and be certain to test the codes to assure they work. Save each program as pa5-1.py, pa5-2.py and so forth.
Exercise 1:
Use the sleep() function from the time module and the randrange() function from the random module to improve your bogus program. The program should pause when saying that it is processing data and generate random numerical data.
Exercise 2:
Use the functions available in the string module to make the chart from the election program print out neatly regardless of what numbers are entered.
Exercise 3:
Write a program that will print the month's calendar for whatever year and month a user enters.
Exercise 4:
Write a program that will calculate the length of the hypotenuse of a right triangle when the user enters the length of the two sides.
Exercise 5:
Create a censoring program. The program should allow users to type in the word they want to have removed from text and the word they want to have in place of the censored word. Then, when the user types in a sentence with the offensive word, the computer should print out the censored version.
Exercise 5 Extension: (5 points extra credit)
Modify your censoring program so that it works regardless of how the censored word is capitalized.
** Extra Credit ** -- 5 Points each. Maximum 20 points.
Research the modules listed in the notes and create a program that implements at least two different functions other than input() and raw_input().
Restricted access |