teslariu

listas3

Jul 8th, 2022
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Crear un script que imprima una lista de los primeros 10 nros, sus
  6. cuadrados y cubos
  7.  
  8. numeros = [1,2,3,4,5,6,7,8,9,10]
  9.  
  10. for numero in numeros:
  11.    print(f"{numero:>3} {numero**2:>4} - {numero**3:>5}")
  12.  
  13.  
  14. """
  15. # Script que hace lo mismo pero para los primeros 1000 nros
  16. for numero in range(1,1001,1):
  17.     print(f"{numero:>12} {numero**2:>12} - {numero**3:>12}")
  18.  
  19. # range:
  20. # 1) completo: range(inicio,tope,incremento)
  21. #        ej: range(14,-5,-3) -> [14,-11,-8]
  22. # 2) con 2 valores range(inicio, tope)    increm por default 1
  23. #        ej: range(-4,-1)  -> [-4,-3,-2]
  24. # 3) range con 1 valor: range(tope) inicio x default cero, inc x default 1
  25. #        ej: range(5)  -> [0,1,2,3,4]
  26.  
  27. # Crear un script que imprima las vocales de una frase ingresada por teclado
  28. frase = input("Ingrese una frase: ")
  29.  
  30. for caracter in frase:
  31.     if caracter in "aeiouAEIOU":
  32.         print(caracter,end="_")
  33.  
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment