################################################### [br]#34 Ejemplos de Imprimir patrones [br]#de números, letras, astericos:[br][br]#1. Imprimir un triángulo de asteriscos:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print('*', end='')[br] print()[br][br]#2. Imprimir un triángulo de números:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print(j+1, end='')[br] print()[br][br]#3. Imprimir un triángulo de letras:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print(chr(65+j), end='')[br] print()[br][br]#4. Imprimir un rombo de asteriscos:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br]for i in range(n-2, -1, -1):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br][br]#5. Imprimir un cuadrado de asteriscos:[br]n = 5[br]for i in range(n):[br] for j in range(n):[br] print('*', end='')[br] print()[br][br]#6. Imprimir un cuadrado de números:[br]n = 5[br]for i in range(n):[br] for j in range(n):[br] print(i+1, end='')[br] print()[br][br]#7. Imprimir un cuadrado de letras:[br]n = 5[br]for i in range(n):[br] for j in range(n):[br] print(chr(65+i), end='')[br] print()[br][br]#8. Imprimir un rectángulo de asteriscos:[br]n = 5[br]m = 10[br]for i in range(n):[br] for j in range(m):[br] print('*', end='')[br] print()[br][br]#9. Imprimir un rectángulo de números:[br]n = 5[br]m = 10[br]for i in range(n):[br] for j in range(m):[br] print(i+1, end='')[br] print()[br][br]#10. Imprimir un rectángulo de letras:[br]n = 5[br]m = 10[br]for i in range(n):[br] for j in range(m):[br] print(chr(65+i), end='')[br] print()[br][br]#11. Imprimir un patrón de asteriscos:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print('*', end='')[br] print()[br]for i in range(n-1, 0, -1):[br] for j in range(i):[br] print('*', end='')[br] print()[br][br]#12. Imprimir un patrón de números:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print(j+1, end='')[br] print()[br]for i in range(n-1, 0, -1):[br] for j in range(i):[br] print(j+1, end='')[br] print()[br][br]#13. Imprimir un patrón de letras:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print(chr(65+j), end='')[br] print()[br]for i in range(n-1, 0, -1):[br] for j in range(i):[br] print(chr(65+j), end='')[br] print()[br][br]#14. Imprimir un patrón de asteriscos en forma de X:[br]n = 5[br]for i in range(n):[br] for j in range(n):[br] if i == j or i+j == n-1:[br] print('*', end='')[br] else:[br] print(' ', end='')[br] print()[br][br]#15. Imprimir un patrón de números en forma de X:[br]n = 5[br]for i in range(n):[br] for j in range(n):[br] if i == j or i+j == n-1:[br] print(i+1, end='')[br] else:[br] print(' ', end='')[br] print()[br][br]#16. Imprimir un patrón de letras en forma de X:[br]n = 5[br]for i in range(n):[br] for j in range(n):[br] if i == j or i+j == n-1:[br] print(chr(65+i), end='')[br] else:[br] print(' ', end='')[br] print()[br][br]#17. Imprimir un patrón de asteriscos en forma de diamante:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br]for i in range(n-2, -1, -1):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br][br]#18. Imprimir un patrón de números en forma de diamante:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print(i+1, end='')[br] print()[br]for i in range(n-2, -1, -1):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print(i+1, end='')[br] print()[br][br]#19. Imprimir un patrón de letras en forma de diamante:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print(chr(65+i), end='')[br] print()[br]for i in range(n-2, -1, -1):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print(chr(65+i), end='')[br] print()[br][br]#20. Imprimir un patrón de asteriscos en forma de pirámide:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br][br]#21. Imprimir un patrón de números en forma de pirámide:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print(i+1, end='')[br] print()[br][br]#22. Imprimir un patrón de letras en forma de pirámide:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print(chr(65+i), end='')[br] print()[br][br]#23. Imprimir un patrón de asteriscos en forma de media pirámide:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print('*', end='')[br] print()[br][br]#24. Imprimir un patrón de números en forma de media pirámide:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print(i+1, end='')[br] print()[br][br]#25. Imprimir un patrón de letras en forma de media pirámide:[br]n = 5[br]for i in range(n):[br] for j in range(i+1):[br] print(chr(65+i), end='')[br] print()[br][br]#26. Imprimir un patrón de asteriscos en forma de media pirámide invertida:[br]n = 5[br]for i in range(n):[br] for j in range(n-i):[br] print('*', end='')[br] print()[br][br]#27. Imprimir un patrón de números en forma de media pirámide invertida:[br]n = 5[br]for i in range(n):[br] for j in range(n-i):[br] print(i+1, end='')[br] print()[br][br]#28. Imprimir un patrón de letras en forma de media pirámide invertida:[br]n = 5[br]for i in range(n):[br] for j in range(n-i):[br] print(chr(65+i), end='')[br] print()[br][br]#29. Imprimir un patrón de asteriscos en forma de rombo:[br]n = 5[br]for i in range(n):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br]for i in range(n-2, -1, -1):[br] for j in range(n-i-1):[br] print(' ', end='')[br] for j in range(2*i+1):[br] print('*', end='')[br] print()[br] [br]#30. Imprimir un triángulo de asteriscos:[br]for i in range(1, 6):[br] for j in range(i):[br] print("*", end="")[br] print()[br] [br]#31. Imprimir un patrón de números:[br]for i in range(1, 6):[br] for j in range(1, i + 1):[br] print(j, end="")[br] print()[br][br]#32. Imprimir un patrón de letras:[br]letra = "A"[br]for i in range(1, 6):[br] for j in range(1, i + 1):[br] print(letra, end="")[br] letra = chr(ord(letra) + 1)[br] print()[br] [br]#33. Imprimir un rombo de asteriscos:[br]for i in range(6):[br] for j in range(6-i):[br] print(' ', end='')[br] for k in range(i+1):[br] print('*', end=' ')[br] print()[br]for i in range(5):[br] for j in range(i+2):[br] print(' ', end='')[br] for k in range(5-i):[br] print('*', end=' ')[br] print()[br][br]#34. Imprimir un patrón de números triangulares:[br]n = 1[br]for i in range(5):[br] for j in range(i+1):[br] print(n, end=' ')[br] n += 1[br] print()