Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- Programa que crea un archivo con temp expresadas en ºC
- y luego genera otro con las mismas temperaturas pero expresadas en ºF
- """
- f = open("centigrado.txt","x")
- datos = ['10ºC\n', '12.5ºC\n', '-18.4ºC\n', '100.22ºC\n']
- f.writelines(datos)
- f.close()
- f = open("centigrado.txt","r")
- lineas = f.readlines()
- f.close()
- f = open("farenheit.txt","x")
- for linea in lineas:
- temp, escala = linea.split("º")
- temp = float(temp) * 1.8 + 32
- f.write("{:.2f}ºF\n".format(temp))
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement