Question

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. The actual user input and reporting of results should not be part of these functions

Homework Answers

Answer #1
def c_to_f(C):
    return ((9/5)*C) + 32

def f_to_c(F):
    return (5/9)*(F-32)

choice = input("Was that input Fahrenheit or Celsius c/f? ")
temp = float(input("Enter a temperature "))
if choice=="c":
    print(temp,"Celsius is",c_to_f(temp),"Fahrenheit")
else:
    print(temp, "Fahrenheit equals", f_to_c(temp), "Celsius")

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
C++ Program: Prompt the user to enter a Fahrenheit degree then using the following formula to...
C++ Program: Prompt the user to enter a Fahrenheit degree then using the following formula to convert it to Celsius degree. Don't accept any value less than -60 and more than 200. C = (5/9)*(F – 32)
On python how do i prompt a user to enter a number but the program is...
On python how do i prompt a user to enter a number but the program is only inclusive for a certain range. For example, prompting the user to enter a number (inclusive with integers between 0 and 10)?
Python 3 Conversion and exception handling Create a function that asks the user to enter a...
Python 3 Conversion and exception handling Create a function that asks the user to enter a number and returns the number. * function name: get_int * parameters: prompt (string) * returns: int * operation: Use the "prompt" parameter as the parameter to an input() call in order to ask the user for a number. Convert the number to a int using the int() function and return this number from the function. but - If the user enters something that cannot...
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...
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale...
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale conversion he/she would like to perform: 1. Convert F to C 2. Convert C to F 3. Quit What is your choice? Then it asks the user for input for three real number variables: start_temp, end_temp, temp_incr. It will then produce a two column Fahrenheit to Celsius table or a two column Celsius to Fahrenheit table, depending on the choice. For choice 1, the...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use of relational and logical operators to check numeric ranges User friendly Use of user friendly user prompt and simple input validation Use of meaningful output labels and format Use of output manipulators Working with string type Use of getline() Project Description There are two main systems for measuring distance, weight and temperature, the Imperial System of Measurement and the Metric System of Measurement. Most...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
Write a Python program to calculate the area of a circle. The user needs to input...
Write a Python program to calculate the area of a circle. The user needs to input the value of the radius of the circle. area = 3.14 x radius x radius You should use a function named circlearea to perform the calculation 3. Write a Python program to calculate the area of a square. The user needs to input the value of the length of the square. area = len*len You should use a function named squarearea to perform the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT