Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specification: Your script must print a Celsius to Fahrenheit conversion table ranging from 0 to 10 degrees Celsius and a Fahrenheit to Celsius conversion table

Specification:

Your script must print a Celsius to Fahrenheit conversion table ranging from 0 to 10 degrees Celsius and a Fahrenheit to Celsius conversion table ranging from 32 to 40 degrees Fahrenheit.

The script must have four functions

celsius_to_fahrenheit

print_celsius_to_fahrenheit_conversion_table

fahrenheit_to_celsius

print_fahrenheit_to_celsius_conversion_table

celsius_to_fahrenheit

This function must have the following header

def celsius_to_fahrenheit(celsius):

This function takes a Celsius value as its parameter and calculates the corresponding Fahrenheit value. The Fahrenheit value must be an integer. The function returns the Fahrenheit value.

print_celsius_to_fahrenheit_conversion_table

This function must have the following header

def print_celsius_to_fahrenheit_conversion_table(min, max):

This function will print a table of Celsius temperatures and their corresponding Fahrenheit values. It must print the column labels "Celsius" and "Fahrenheit". It then prints out a line of dashes, -. This must be followed by a loop between the minimum and maximum values. Each pass through the loop should print a Celsius value and the corresponding Fahrenheit value. The temperature values should line up with the labels at the top of the table.

fahrenheit_to_celsius

This function must have the following header

def fahrenheit_to_celsius(fahrenheit):

This function takes a Fahrenheit value as its parameter and calculates the corresponding Celsius value. The Celsius value must be an integer. The function returns the Celsius value.

print_fahrenheit_to_celsius_conversion_table

This function must have the following header

print_fahrenheit_to_celsius_conversion_table(min, max):

This function will print a table of Fahrenheit temperatures and their corresponding Fahrenheit values. It must print the column labels "Fahrenheit" and "Celsius". It then prints out a line of dashes, -. This must be followed by a loop between the minimum and maximum values. Each pass through the loop should print a Fahrenheit value and the corresponding Celsius value. The temperature values should line up with the labels at the top of the table.

Test Code

The script must contain the following test code at the bottom of the file

min_celsius = int(input("Minimum Celsius temperature: ")) max_celsius = int(input("Maximum Celsius temperature: ")) print() print_celsius_to_fahrenheit_conversion_table(min_celsius, max_celsius) print() min_fahrenheit = int(input("Minimum Fahrenheit temperature: ")) max_fahrenheit = int(input("Maximum Fahrenheit temperature: ")) print() print_fahrenheit_to_celsius_conversion_table(min_fahrenheit, max_fahrenheit)

Suggestions:

Write this script in stages, testing your script at each step

Create the script and paste into it the test code above. Create the headers for each of the four functions. For the body of each of the functions, add the single Python statement pass. Running the script should only ask you for four values. Fix any errors you find.

Remove the pass statement in celsius_to_fahrenheit. Replace it with code that calculates the Fahrenheit value for a Celsius temperature and assigns it to a variable. Add a statement that returns the Fahrenheit value. Add the following line to the test code

print(celsius_to_fahrenheit(0))

Run the script and fix any errors.

Remove the test code above. Remove the pass statement from print_celsius_to_fahrenheit_conversion_table. Add a print statement to print the column labels. Add a print statement to print a line of dashes. Run the script and fix any errors.

Add a loop that runs from the maximum to minimum temperatures. Inside the loop, print the Celsius values. Run the script and fix any errors.

Change the print statement inside the loop to print the Fahrenheit values along with the Celsius values. Run the script and fix any errors.

Repeat the steps above with the other two functions.

Output:

Your output should look like this

$ python3 hw7.py Minimum Celsius temperature: 0 Maximum Celsius temperature: 10 Celsius Fahrenheit ------------------ 0 32 1 34 2 36 3 37 4 39 5 41 6 43 7 45 8 46 9 48 10 50 Minimum Fahrenheit temperature: 32 Maximum Fahrenheit temperature: 39 Fahrenheit Celsius ----------------------- 32 0 33 1 34 1 35 2 36 2 37 3 38 3 39 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

What are some of the possible scenes from our future?

Answered: 1 week ago

Question

1. What are your creative strengths?

Answered: 1 week ago