-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachorroLab8.py
More file actions
31 lines (28 loc) · 826 Bytes
/
MachorroLab8.py
File metadata and controls
31 lines (28 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#Gary Machorro
#8/24/17
#Lab8:temp conversion
try:
infile=open("C:\\Users\\gfmachorro\\Downloads\\tempF.txt","r")
outfile=open("C:\\Users\\gfmachorro\\Downloads\\tempsC.txt","w")
tempList=[]
floatList=[]
stringList=[]
for line in infile:
line=line.rsplit()
tempList=tempList+line
for i in range(len(tempList)):
temp=float(tempList[i])
floatList.append(temp)
print(floatList)
for j in range(len(floatList)):
tempC=((floatList[j])-32)*(5/9)
tempC=round(tempC,2)
stringList.append(tempC)
for k in range(len(stringList)):
Ctemps=str(stringList[k])
outfile.write(Ctemps)
outfile.write("")
infile.close()
outfile.close()
except IOError:
print("File not found.")