Ask Question

python Write a program that will take a file named Celsius. dat that contains a list of temperatures in Celsius (one per line), and will create a file Fahrenheit. dat that contains the same temperatures (one per line, in the same order) in Fahrenheit

+2
Answers (1)
  1. 13 March, 19:10
    0
    with open ('celcius. dat', 'r') as fIn, open ('fahrenheit. dat', 'w') as fOut:

    for line in fIn:

    fahrenheit = 9.0 / 5.0 * float (line) + 32

    fOut. write ("%.1f/n" % fahrenheit)

    You can control the number of decimals in the formatting clause in the write statement.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “python Write a program that will take a file named Celsius. dat that contains a list of temperatures in Celsius (one per line), and will ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers