Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Crear un script que imprima una lista de los primeros 10 nros, sus
- cuadrados y cubos
- numeros = [1,2,3,4,5,6,7,8,9,10]
- for numero in numeros:
- print(f"{numero:>3} {numero**2:>4} - {numero**3:>5}")
- """
- # Script que hace lo mismo pero para los primeros 1000 nros
- for numero in range(1,1001,1):
- print(f"{numero:>12} {numero**2:>12} - {numero**3:>12}")
- # range:
- # 1) completo: range(inicio,tope,incremento)
- # ej: range(14,-5,-3) -> [14,-11,-8]
- # 2) con 2 valores range(inicio, tope) increm por default 1
- # ej: range(-4,-1) -> [-4,-3,-2]
- # 3) range con 1 valor: range(tope) inicio x default cero, inc x default 1
- # ej: range(5) -> [0,1,2,3,4]
- # Crear un script que imprima las vocales de una frase ingresada por teclado
- frase = input("Ingrese una frase: ")
- for caracter in frase:
- if caracter in "aeiouAEIOU":
- print(caracter,end="_")
Advertisement
Add Comment
Please, Sign In to add comment