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....
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a non-negative integer value a. The script should then evaluates the sum Pn i=1 i a using a running sum for the case when n = 5. More specifically, use a counter for i that is used in the output fprintf as well as in the running sum. Feel free to write some code and just repeat it 5 times in your script. Sample...
By using Python code answer the following parts: A) Write a program to ask the user...
By using Python code answer the following parts: A) Write a program to ask the user to input their name and then output the type and length of the input. B) Write a program to output the last 11 letters of 'Introduction to Indiana'. C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'. D) Write a program to ask the user to input a float number and output the rounded value of it...
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
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/)...
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.
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED....
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED. ALSO THE 2 POINTS MENTIONED BELOW SHOULD BE PRESENT IN THE CODE Write a script that calculates the 3 longest words of a text stored in a file and print them from the longest to the smaller of the 3. Please note: 1. The name of the file is word_list.csv and it doesn’t need to be asked to the user (meaning the name will...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT