-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractica.py
More file actions
49 lines (42 loc) · 1.17 KB
/
Copy pathpractica.py
File metadata and controls
49 lines (42 loc) · 1.17 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Escribir un programa que realice conversiones de temperaturas
"""
temperatura, escala= input("Ingrese temperatura y escala\n" ).upper().split(" ")
seleccion = input("¿A que escala desea convertir?"
'\n1. C'
'\n2. F'
'\n3. K\n').upper()
temperatura = float(temperatura)
while seleccion == "C":
if escala == 'F':
#Convertir Fahrenheit a Celsius
celsius = 5/9 * (temperatura - 32)
print(f"{celsius:.2f} Celsius")
break
#Convertir Kelvin a Celsius
if escala == 'K':
celsius = temperatura - 273.15
print(f"{celsius:.2f} Celsius")
break
while seleccion == "F":
if escala == 'C':
#Convertir Celsius a Fahrenheit
fahrenheit = 9/5 * temperatura + 32
print(f"{fahrenheit:.2f} Fahrenheit")
break
#Convertir Kelvin a Fahrenheit
if escala == 'K':
fahrenheit = 9/5 * (temperatura-273.15) + 32
print(f"{fahrenheit:.2f} Fahrenheit")
break
while seleccion == "K":
if escala == 'C':
#Convertir Fahrenheit a Kelvin
kelvin = 5/9*(temperatura-32) + 237.15
print(f"{kelvin:.2f} Kelvin")
break
#Convertir Celsius a Kelvin
if escala == 'F':
kelvin = temperatura + 273.15
print(f"{kelvin:.2f} Kelvin")
break