satya

Friday, October 23, 2020

Program 26

                                                                 Program 26

Write a program that reads a list of temperatures from a file called temps.txt, converts those temperatures to Fahrenheit, and writes the results to a file called ftemps.txt.


file=open('temps.txt','r')

l=file.readlines()

f=open('ftemps.txt','w')

for line in range(len(l)):

    d=l[line].strip()

    fahrenheit = (float(d) * 9/5) + 32

    f.write(str(fahrenheit)+"\n")

f.close()

OUTPUT


No comments:

Post a Comment

Program 30

                                                                         Program 30 Write a Python class to implement pow(x, n). class Pow1:...