$30
Temperature Conversion Table – Loop Practice
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. (Find the Celsius to Fahrenheit conversion formula on the Internet.) The table should include rows for all temperatures between 0 and 100 degrees Celsius that are multiples of 10 degrees Celsius. Include a heading and a title. Here’s how the table might look:
Celsius to Fahrenheit
Conversion Table
Celsius Fahrenheit
0 32
10 50
and so on.
This problem is derived from The Python Workbook, by Ben Stephenson, page 30, exercise 63.
2. Below and Above Average – List Practice
Write a program that reads numbers from a user and places them into a list. Stop entering numbers when the user enters a 0. Don’t put the 0 in the list. Display the average of all the numbers in the list. Then in three displays one after the other, display all numbers that are below the average, that equal the average, and that are above the average. Include an appropriate title at the start of each of the three lists. Allow for the possibility that there are no numbers below the average and/or no numbers above the average. (What does that mean about the numbers in the list?)
This problem is derived from The Python Workbook, by Ben Stephenson, page 52, exercise 112.
3. Canadian Postal Codes – Dictionary Practice
In a Canadian postal code (zip code), the first, third and fifth characters are letters, while the second, fourth and sixth characters are digits. There is a space between the third and fourth characters for a total length of 7. A Canadian province can be determined from the first character of a postal code, as shown in the table below. No valid postal codes currently begin with D, F, I, O, Q, U, W, or Z. Create a dictionary from this table:
Province
First character(s)
Newfoundland
A
Nova Scotia
B
Prince Edward Island
C
New Brunswick
E
Quebec
G, H and J
Ontario
K, L, M, N, and P
Manitoba
R
Saskatchewan
S
Alberta
T
British Columbia
V
Nunavut
X
Northwest Territories
X
Yukon
Y
Note that the letter X can mean Nunavut or Northwest Territories. The second character indicates rural or urban addresses: 0 means a rural address, anything else an urban address.
Write a program that loops to read a postal code from a user. The program ends when the user presses just the <Enter key in response to your prompt. If the user entered a postal code, validate it first. The string must be seven characters long (otherwise it is invalid) and cannot begin with the letters D, F, I, O, Q, U, W, or Z (which would make the entry invalid). If the first letter is valid, display the province associated with the letter and whether the address is urban or rural. For example, for T2N 1N4, your program should display that the address is an urban one in Alberta. For X0A 1B2, your program should display that the address is a rural one in Nunavut or Northwest Territories. Display a meaningful message if the postal code is invalid.