Write a program that asks the user to enter an input file name and to specify an output file name. Then the program reads the content of the input file, and read the data in each line as a number (double). These numbers represent the temperatures degrees in fahrenheit for each day. The program should convert the temperature degrees to celsius and then writes the numbers to the output file, with the number of days added to the beginning of the temperature record.
Answers
Answered by
0
Python Code:
temp = input("Input the temperature you like to convert? (e.g., 45F, 102C etc.) : ")
degree = int(temp[:-1])
i_convention = temp[-1]
if i_convention.upper() == "C":
result = int(round((9 * degree) / 5 + 32))
o_convention = "Fahrenheit"
elif i_convention.upper() == "F":
result = int(round((degree - 32) * 5 / 9))
o_convention = "Celsius"
else:
print("Input proper convention.")
quit()
print("The temperature in", o_convention, "is", result, "degrees.")
Similar questions
English,
6 months ago
Math,
6 months ago
Hindi,
6 months ago
Computer Science,
11 months ago
Physics,
1 year ago