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

Respuesta :

tonb

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.

fichoh

The program reads in the Celcius temperature in a file and creates a file with the temperature value expressed on Fahrenheit. The program written in python 3 goes thus ;

with open('celcius.dat', 'r') as file1

, open('fahrenheit.dat', 'w') as file2:

#opens the Celcius file in read mode and creates a new file fahrenheit.dat in write mode

for line in file1:

#loop through each line in the Celcius file

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

#using the fahrenheit conversion formula, convert the Celcius temperatures and assign to the fahrenheit variable

file2.write("%.1f\n" % fahrenheit)

#f write the converted values into the file2

Learn more : https://brainly.com/question/19323897

ACCESS MORE
EDU ACCESS