Question
Python 3.7 1. Write a program that converts temperature from F, C, K using functions. PLEASE EDIT THIS CODE I ALREADY HAVE TO INCLUDE KELVIN
Python 3.7 1. Write a program that converts temperature from F, C, K using functions.
PLEASE EDIT THIS CODE I ALREADY HAVE TO INCLUDE KELVIN
def convert_to_fahrenheit(temp):
result = 9/5 * temp + 32
return result
def convert_to_celsius(temp): result = 5/9 * (temp-32)
return result
# where the fun begins
temperature = int(input("Enter degrees: "))
scale = input("Enter C for Celsius or F for Fahrenheit: ")
scale = scale.strip().upper()
if scale == "C":
converted_temp = convert_to_fahrenheit(temperature)
print("The temperature in Fahrenheit is %.2f." % converted_temp)
elif scale == "F": converted_temp = convert_to_celsius(temperature)
print("The temperature Celsius is %.2f." % converted_temp)
else: print("Wrong answer")
Please edit this code to include the conversion for Kelvin as well. thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started