IT 116: Introduction to Scripting
Homework 6

Due Sunday, October 15th at 11:59 PM

Deliverables

There is one deliverable for this assignment It must be in an hw6 directory, which you must create inside a hw directory inside you it116 directory.

Make sure the script obeys all the rules in the Script Requirements page.

Specification

Your script should ask the user for a minimum Celsius temperature and then a maximum Celsius temperature.

It should then print out a Celsius to Fahrenheit conversion table for this range of Celsius temperatures.

The table should have the same format as in homework 5.

This script must contain two functions

print_table_line

This function must have the following header
def print_table_line(celsius)
This function prints one line in the table.

The line consists of the Celsius temperature, a tab, and the Fahrenheit temperature.

It should print a line that looks like this
0   32
In order to do this, the function must first convert the Celsius temperature into a Fahrenheit value.

Both temperatures must be integers.

print_conversion_table

This function must have the following header
def print_conversion_table(min, max):
This function does four things
  1. Prints the words "Celsius" and "Fahrenheit" to label the columns
  2. Prints a line of dashes, -
  3. Have a for loop
  4. Call print_table_line(celsius) inside the loop

The for loop variable must range from the minimum Celsius temperature to the maximum Celsius temperature.

Each pass through the loop must call print_table_line(celsius) with a Celsius value.

Suggestions

  1. Create the header for the function print_table_line(celsius).
    or the body of the function write I print statement that simply prints the value of the celsius parameter.
    Add the following statement after at the bottom of the script
    print_table_line(30)
    Run the code and fix any errors.
  2. Above the print statement in print_table_line define the variable farhrenheit and on the right side of the assignment statement calculate the value of the Fahrenheit temperature using the celsius parameter.
    Change the print statement so it print both the celsius and fahrenheit values.
    Run the code and fix any errors.
  3. Remove the print statement at the bottom of the script.
    Add the test code below to the bottom of your script.
    Create the header for the print_conversion_table function.
    Add a print statement that prints the labels "Celsius" and "Fahrenheit".
    Add a print statement that prints a line of dashes, -.
    Run the code and fix any errors.
  4. Add a for loop will a loop variabale that will run from the minimum to the maximum given by the parameters.
    In the for loop add a print statement that prints the loop variable.
    Run the code and fix any errors.
  5. Remove the print statement under the for loop.
    In its place call the function print_table_line with the celsius value as the argument.
    Run the code and fix any errors.
  6. Adjust the print statement in print_table_line so it lines up with the labels printed by print_conversion_table.
    Run the code and fix any errors.

Testing

The following test code must be added to the bottom of your script
min = int(input("Please enter the starting temperature for the table: "))
max = int(input("Please enter the ending temperature for the table: "))
print()
print_conversion_table(min, max)
Your output should look something like this
python3 hw6.py 
Please enter the starting temperature for the table: 10
Please enter the ending temperature for the table: 15

Celsius	Fahrenheit
------------------
10	50
11	52
12	54
13	55
14	57
15	59
The text in blue is what you enter at the command line.

Be sure to run this script on the Unix machine so you know it works in the environment in which I will run it when I score your homework.