1. Write a program that reads in an integer representing a Celsius value and writes it out as a Fahrenheit value. If the Celsius value is C, then the Fahrenheit value, F, is calculated as follows: F = ( 9.0 / 5.0 ) * C + 32. [ Hint: recall the raw_input() and input() functions for user input. ]
2. Write a program that reads in two numbers from the user and writes out which number divides exactly into the other, if either do. [ Hint: first write a function divisorOneWay( a, b ) that takes two integer parameters and returns True if the second parameter divides exactly into the first, and False otherwise, second write a related function divisor( a, b ) that returns True if either number divides exactly into the other, and False otherwise. ] Example input and output is:
3. Write a program that reads in a sequence of positive numbers typed by the user. You should stop reading numbers when the user types -1. a) Write out how many numbers were typed in by the user. b) Calculate the sum of the numbers typed in by the user, and write it out. c) Find the average of the numbers and write it out. d) Find and write out the largest number. e) Do the same with the smallest number. e) Find out how many times the number 39 was entered and write this out.
4. Here's a small program to illustrate how to use Tkinter and its components in a GUI program - example.py. Here's a screenshot of a program. The lines on the screen look like curved lines, but in fact they are all straight lines. Work out how the lines are related to each other. What is the difference in terms of start/end points between adjacent lines? Write a program to draw this figure.
5. A palindrome is a word/sentence reading the same from left to right or right to left. "civic" is an example of a single word that is a palindrome.
6. Write a function join that takes two lists and returns a list in which each element is a list of two elements, one from each of the given lists. For example:
7. Define a function frequency which is given a string and returns the number of occurrences of each letter in the string, ignoring differences between upper and lower case and ignoring non-letter characters. For example:
8. Define a function wordFrequency which is given a string and returns a dictionary with strings as keys and numbers as values, showing how many times each word occurs in the original string. The function should ignore difference between upper and lower case letters as well as non-letter characters. For example:
9. Birthday book project. The idea is to store people's birthdays and produce reminders of birthdays that are coming up. A birthday consists of a month and a date, which can be represented by a dictionary:
The birthday book is a dictionary in which the keys are people's names and the values are birthdays, represented as dictionaries as above. All the functions that have to be implemented take a birthday book as a parameter:
10. Write out the 12 times table, e.g.
11. Write a function raise that takes two parameters, x and y, and returns the value generated by raising x to the power of y. Do not use Python's ** operator - work out how to generate the answer using a loop.
12. Read in a sequence of integers from the user, ending in -1. These integers represent altitude readings while going on a walk, taken every minute. Your program should calculate how many hill-tops have been encountered on the walk. For example:
13. Using the Tkinter module, write a function grid taking two parameters n and m to draw a grid with n boxes accross by m boxes high. Hence grid(5, 4) would produce a grid of 4 rows with each row having 5 squares.
14. Write a similar function to grid, only this time a chessboard-pattern should be created, of alternating white and black squares.
15. Create the effect of a coin spinning on its edge. This will be an animation with a sequence of ovals appearing with changing shapes. Use trigonometry to work out how the oval should be each time you draw it. Remember that the canvas method .create_line(x1, y1, x2, y2) draws an oval inside the bounding rectangle defined by the parameters.
16. Using Tkinter, write a program that reads in an integer from the user, and then writes it out using Tkinter functions in seven-segment format - like in a digital display, where each digit is made up of some of the seven segments of an '8' shape, drawn using 7 short lines.