Question

Using Python, write the following code. You are to allow the user to enter the daily...

Using Python, write the following code.

You are to allow the user to enter the daily temperature as a floating-point number. You should make the assumption that you are recording temperatures in Fahrenheit.

You should allow the user to continue entering temperatures until the value -999 is entered. This number should not be considered a temperature, but just a flag to stop the program. As the user enters a temperature, you should display the following each time:

Current Temperature: 999 F                   999 C                   

Highest Temperature so far                     999 F                    999 C

Lowest Temperature so far:                     999 F                    999 C

Average Temperature so far:                  999 F                    999 C

Note: As much as reasonably possible, the code should be broken down into smaller functions.

Note: you to read a value, process the value, and then throw it away, you do not need an array or a list.

Note: You need to search the WWW to find an equation to convert Fahrenheit into Celsius

Submission Requirements:

  • You are to write your source code and create a source code document. You are to create your design tool. You are to attach the *.py source code and your design tool document to the Canvas assignment thread.

Homework Answers

Answer #1

Python code:

def ftoc(f):#function to convert Fahrenheit to celcius

    return((f-32)*5/9)#return celcius

ctemp=int(input())#accept current temperature

htemp=ctemp#initial high temperature

ltemp=ctemp#initial low temperature

atemp=ctemp#initial average temperature

count=0#variable for finding average

while(ctemp!=-999):#loop till -999 is obtained as input

    print("Current Temperature: "+str(ctemp)+"F"+"                   "+str(ftoc(ctemp))+"C")#printing Current Temperature in Fahrenheit and celcius

    if(ctemp>htemp):#checking if new value is the highest

        htemp=ctemp#setting high temperature as current temperature

    print("Highest Temperature so far: "+str(htemp)+"F"+"                   "+str(ftoc(htemp))+"C")#printing highest Temperature in Fahrenheit and celcius

    if(ctemp<ltemp):#checking if new value is the lowest

        ltemp=ctemp#setting low temperature as current temperature

    print("Lowest Temperature so far: "+str(ltemp)+"F"+"                   "+str(ftoc(ltemp))+"C")#printing lowest Temperature in Fahrenheit and celcius

    atemp=(atemp*count+ctemp)/(count+1)#setting average temperature

    print("Average Temperature so far: "+str(atemp)+"F"+"                   "+str(ftoc(atemp))+"C")#printing average Temperature in Fahrenheit and celcius

    ctemp=int(input())#accept current temperature

    count+=1#incrementing count


Screenshot of code:

Input:

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
Classwork_1.5: Write a C code that ask the user to enter the name of person, gender...
Classwork_1.5: Write a C code that ask the user to enter the name of person, gender (male or female) and age and display these quantities. You need to create a structure to solve this problem. Output:
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The...
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The program finds and displays the three digits in the number. The program also calculates and displays the sum of the three digits. A sample run is shown below: Enter a number between 100 and 999: 528 The three digits in the number are: 5 2 8 The sum of the three digits is: 15 Note: You must use integer division and modulo division to...
step by step in python please The program will prompt the user as to whether you...
step by step in python please The program will prompt the user as to whether you want to convert from Celsius to Fahrenheit or from Fahrenheit to Celsius Write it so each conversion is contained within its own function (i.e., one function to do the math in one direction, a second to do the math in the other direction) These two functions should just have the input temperature as a parameter and return the output temperature in the other units....
Browse the web and find a site that does not contain a user survey form. Write...
Browse the web and find a site that does not contain a user survey form. Write a user survey with 10 questions that you would use on the site. Tailor the questions to the site’s content and goals. The survey’s questions have to be real, any irrelevant question may lead to mark deduction. a. Restrict the user options with radio buttons, dropdown lists, check boxes, etc. b. Design a wireframe that includes the survey, using a tool like pencil (http://pencil.evolus.vn/)...
**C code only In this part, you will write a simple user-defined function that prints a...
**C code only In this part, you will write a simple user-defined function that prints a message. This function does not require any parameters or return value. The purpose is simply to get you started writing functions.Open repl project Lab: User-Defined Functions 1. Write a program that calls a function. This function should do the following: 1.Ask the user their name 2. Print a "hello" message that includes the user's name Example output: Please enter your name: ​Mat Hello, Mat!...
Write the C++ language statements to ask a user to enter a number within the range...
Write the C++ language statements to ask a user to enter a number within the range of 0 to 100 (0 and 100 are valid inputs). When the value is not valid, you should prompt the user to enter another value. (The user may enter many invalid numbers, so you must use loop). Only after the user enters a valid number should you display the message “Good” and the value of the number.
Using python 3.5 or later, write the following program. A kidnapper kidnaps Baron Barton and writes...
Using python 3.5 or later, write the following program. A kidnapper kidnaps Baron Barton and writes a ransom note. It is not wrriten by hand to avoid having his hand writing being recognized, so the kid napper uses a magazine to create a ransom note. We need to find out, given the ransom note string and magazine string, is it possible to given ransom note. The kidnapper can use individual characters of words. Here is how your program should work...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
(Do this in C++ please and make sure no compile/run errors): I. Write a function that...
(Do this in C++ please and make sure no compile/run errors): I. Write a function that writes a series of random Fahrenheit temperatures and their correspond- ing Celsius temperatures to a tab-delimited file. Use 32 to 212 as your temperature range. From the user, obtain the following: 1. The number of temperatures to randomly generate. 2. The name of the output file. A sample run is included below (you must follow the format provided below): Please enter the name of...