QuestionQuestion

1. Ask the user to enter the number of temperature readings to convert. Make sure the entered value is a number. You must use exception handling (try/catch) to make sure a valid number is entered. For example, a100.8 is an invalid entry. The input such as abc will also be invalid. Make sure to ask the user for a valid input. You must use a loop to validate the entry.
2. Once you have a correct number of items, allow the user to enter a series of temperature values in degrees Fahrenheit. Make sure that each temperature value is between -100 and 100 (inclusive) degrees Fahrenheit.
3. Calculate each temperature data to degrees Celsius using the formula: Celsius = (Fahrenheit – 32) / 1.8. So, if the user enters 100 degrees Fahrenheit, the equivalent temperature in Celsius will be 37.78. You should use the %.2f format specifier in your print statement to format the output.
4. Calculate the total and average of temperature values in degrees Fahrenheit and degrees Celsius. Display all values to the screen.
5. Ask the user for a file name and write the same values in step 4 to an output file.

SAMPLE RUN:
Enter number of data items: abc
INVLAID entry: Input must be a number - try again: a10.7
INVLAID entry: input must be a positive number - try again: 3
Enter temperature in degrees Fahrenheit: 100
Degrees Celsius = 37.78
Enter temperature in degrees Fahrenheit: 1000
Invalid temperature value – try again: -1000
Invalid temperature value – try again: 80
Degrees Celsius = 26.67
Enter temperature in degrees Fahrenheit: 50.3
Degrees Celsius = 10.17
Total temperature in degrees Fahrenheit = 230.30
Total temperature in degrees Celsius = 76.77
Average temperature in degrees Fahrenheit = 74.61   
Average temperature in degrees Celsius = 24.87

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

num_of_data = input('Enter number of data items: ') # ask the user to enter the number of data items
    while True:
       try:
            int_value = int(num_of_data) # check if the input value is number
            if int_value >= 0: # check if the input value is greater than zero
                # if the input value is number and it is greater than zero, break iteration
                break
            else:
                # if the input value is number but not greater than zero
                # ask the user to enter positive number
                num_of_data = input('INVALID entry: input must be a positive number - try again: ')
       except (NameError, ValueError):
            # if the input value is not number ask the user to enter a number
            num_of_data = input('INVALID entry: Input must be a number - try again: ')
   
    temperatures_C = [] # make an empty list to store obtained values
    temperatures_F = [] # make an empty list to store input values...

By purchasing this solution you'll be able to access the following files:
Solution.py.

$13.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats