ejer 16_ejemplos divertidos python tu_y_yo_ para primera parte tecnologías inteligentes 1 bach con notebook ( o Geany 1 bach TICS)
#Ejercicio 1, legend
fila = 1
while fila <=5:
columna = 0
while columna <=9:
columna +=1
print (fila,"*",columna,"=",fila*columna)
fila += 1
print ()
"""
Solución para GoogleColab, por ejemplo
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
1 * 5 = 5
1 * 6 = 6
1 * 7 = 7
1 * 8 = 8
1 * 9 = 9
1 * 10 = 10
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
...
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50"""
#Ejercicio 2
altura = int (input ("Dime la altura del triangulo"))
for fila in range (1,altura+1):
columna = 0
for columna in range (fila):
print ("*", end="")
print()
SOLUCIÖN
*
**
***
****
*****
#ejercicio 3
numero = int (input ("Dime un numero"))
contador =0
for fila in range (1,numero+ 1):
for columna in range (numero):
contador = contador +1
print (contador,"",end="")
print ()
"""
solución:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
"""
# Ejercicio 4: Mostrar el menu
while opcion != 0:
print ("VENTA DE ENTRADAS")
print ("1.- Consultar stock")
print ("2.- Vender entradas")
print ("3.- Consultar recaudación")
print ("0.- Salir del programa")
#Vamos a pedir una opcion
opcion = int (input ("Seleccione una opción (0-3)"))
#Vamos a comparar las diferentes opciones
if opcion == 1:
print ("Consultar stock")
elif opcion == 2:
print (" Vender entradas")
elif opcion == 3:
print ("Consultar recaudacion")
else:
print ("Opción no válida")
print ("Vuelve pronto")
"""
solución
VENTA DE ENTRADAS
1.- Consultar stock
2.- Vender entradas
3.- Consultar recaudación
0.- Salir del programa
Opción no válida
Vuelve pronto
"""