Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # bucle indefinido: while
- """
- i = 0
- while i < 5:
- print(i)
- continue # reinicia el ciclo
- i = i + 1
- print("Chau")
- # script que imprime verticalmente una lista de nombres con while
- # no es lo ideal, habría que hacerlo con for
- lista_de_nombres = ["Alan", "Zoilo", "Abel", "Marta", 'Jorge', "Carina"]
- i = 0
- while i < len(nombres):
- print(nombres[i])
- i = i + 1
- # SPOILER (de for):
- for nombre in lista_de_nombres:
- print(nombre)
- """
- # Script que convierte temp de ºF a ºC y viceversa
- while True:
- print("""
- Menu de opciones
- ----------------
- 1. ºC -> ºF
- 2. ºF -> ºC
- 3. Salir
- -------------------
- """)
- opcion = input("Seleccione su opción: ")
- if opcion == "1":
- temp = float(input("Temp: "))
- print(f"{temp * 1.8 + 32:.1f}ºF")
- elif opcion == "2":
- temp = float(input("Temp: "))
- print(f"{(temp - 32) / 1.8:.1f}ºC")
- elif opcion == "3":
- print("Adios...")
- break
- else:
- print("Opción incorrecta..")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement