Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions Ejercicios_lvl1/AirlineTravel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Por Felipe (ZenTial)

# 5. Turkish Airlines has just launched an offer to travel among the following destinations: Turkey, Greece, Lebanon,
# Spain, and Portugal. Develop an algorithm with the following characteristics: It must have a login and validate the
# data; after the third failed attempt, it should be locked. The user must choose the origin country and the
# destination country, the flight date, and the condition: Economy or First Class. The user must choose if they want
# to check an additional piece of luggage into the hold. Hand luggage is free of charge. The user must purchase both
# the outbound and return tickets. The user can choose their preferred meal: Regular, Vegetarian, Kosher. The program
# must collect the following data: Name, country of origin, passport, and destination country. Upon completing the
# process, the system will display everything the user has previously chosen along with their information. The system
# will provide the option to confirm the reservation or cancel it. If the user chooses YES, a confirmation message
# will appear. If not, it will return to the main menu.
from os import system
import re

# Declaración de variables
destinos = ['turquia', 'grecia', 'lebanon', 'españa', 'portugal']
comidas = ['regular', 'vegetariana', 'kosher']


# Función de inicio de sesión
def inicio_sesion():
usuario = 'admin'
password = 'python'
intentos = 0
while True:
try:
usuario_input = input('Ingrese un usuario: ')
contrasena_input = input('Ingrese una contraseña: ')
[usuario].index(usuario_input)
[password].index(contrasena_input)

except ValueError:
intentos += 1
system('cls')
print('Ingresa las credenciales correctas.')

else:
system('cls')
return True

finally:
if intentos == 3:
system('cls')
print('El sistema ha sido bloqueado debido a que ha hecho muchos intentos')
return False


# Función para calcular el precio según la cantidad de equipaje
def cantidad_equipaje():
while True:
try:
cantidad = input('Cuantas maletas extra va a llevar?: ')
precio = int(cantidad) * 20
except TypeError:
system('cls')
print('Error, elige un valor que sea un número')
else:
return precio


# Función para el equipaje adicional
def equipaje_adicional(lista):
precio_total = 200
while True:
try:
equipaje = input('¿Desea llevar equipaje adicional? [S/N]: ')
print('Se le cobraran $20 extra por cada equipaje')
['s', 'n'].index(equipaje)
except ValueError:
system('cls')
print('Error, ingrese una opción valida')
else:
if equipaje == 'n':
lista[5] = precio_total
return lista
else:
precio = cantidad_equipaje()
precio_total += precio
lista[5] = precio_total
return lista


# Función para decidir si confirmar datos o volver al menú
def imprimir_confirmar(lista):
nombre = input('Escriba su nombre: ')
passport = input('Escriba la id de su pasaporte: ')
while True:
system('cls')
print('*' * 50)
print(f'Nombre: {nombre}\nId de pasaporte: {passport}\nPaís de origen: {lista[0]}\n'
f'País de destino: {lista[1]}\nFecha de vuelo: {lista[2]}\nComida preferida: {lista[3]}\n'
f'Tipo de billete: {lista[4]}\nPrecio total: ${lista[5]}')
try:
reservacion = input('¿Desea confirmar la reservación? [S/N]: ')
['s', 'n'].index(reservacion)
except ValueError:
system('cls')
print('Error, elija una opción valida')
else:
return reservacion


# Función para la preferencia de comida
def comidaycondicion(lista):
while True:
print('*' * 50)
print('Elige tu tipo de comida preferida de esta lista: ')
for comida in comidas:
print(comida.capitalize())
try:
comida_elegida = input('Elige tu comida: ').lower()
comidas.index(comida_elegida)
system('cls')
condicion_viaje = input('¿Desea ir en Primera clase o en clase Economica?: ').lower()
['primera clase', 'economica'].index(condicion_viaje)
except ValueError:
system('cls')
print('Error, elige un tipo de comida valido')
else:
lista[3] = comida_elegida.capitalize()
lista[4] = condicion_viaje.capitalize()
return lista


# Función para la fecha de vuelo
def fecha_vuelo(lista):
patron = r'\d{2}-\d{2}'
while True:
print('*' * 50)
try:
vuelo = input('Escriba la fecha de su vuelo en el siguiente formato (%%-%%): ')
confirmacion = re.search(patron, vuelo).group()
except AttributeError:
system('cls')
print('Error, ingrese un tipo de fecha valido')
else:
lista[2] = confirmacion
return lista


# Función del menú
def menu(lista):
while True:
print('*' * 50)
print('Bienvenido a nuestras aerolineas, ambos billetes de ida y vuelta cuestan $100')
for destino in destinos:
print(destino.capitalize())
try:
pais_origen = input('De esta lista, elige tu país de origen: ').lower()
destinos.index(pais_origen)
pais_destino = input('De esta lista, elige tu país de destino: ').lower()
destinos.index(pais_destino)
except ValueError:
system('cls')
print('Error, escriba un país valido')
else:
lista[0] = pais_origen.capitalize()
lista[1] = pais_destino.capitalize()
return lista


# Función main del programa
def main():
inicio_sesion()
while True:
lista_datos = ['', '', '', '', '', '']
system('cls')
lista_datos = menu(lista_datos)
system('cls')
lista_datos = fecha_vuelo(lista_datos)
system('cls')
lista_datos = comidaycondicion(lista_datos)
system('cls')
lista_datos = equipaje_adicional(lista_datos)
system('cls')
confirmacion = imprimir_confirmar(lista_datos)
if confirmacion == 's':
system('cls')
print('Gracias por usar nuestro servicios')
return
else:
continue


if __name__ == '__main__':
main()
204 changes: 204 additions & 0 deletions Ejercicios_lvl1/CoachManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# Por Felipe (ZenTial)
# 1. Manchester United FC has hired you as a developer. Develop a program that helps the coach identify their fastest player, player with the most goals, assists, passing accuracy, and defensive involvements.
# The program functions as follows: The coach accesses the system and encounters a menu with the following options:
# Player Review: By entering the player's jersey number, they can access the player's characteristics.
# Compare two players: The system prompts for two jersey numbers and displays the data of both players on screen.
# Identify the fastest player: Displays the player with the most points in speed.
# Identify the top goalscorer: Displays the player with the most points in goals.
# Identify the player with the most assists: Displays the player with the most points in assists.
# Identify the player with the highest passing accuracy: Displays the player with the most points in passing accuracy.
# Identify the player with the most defensive involvements: Displays the player with the most points in defensive involvements.
# The system should also allow returning to the main menu.
from os import system

# Declaración de variables

camiseta_8 = {'nombre': 'Bruno Fernandes', 'goles': 5, 'puntos velocidad': 6,
'puntos asistencia': 9, 'puntos precision pase': 10, 'participacion defensiva': 3}
camiseta_11 = {'nombre': 'Rasmus Hojlund', 'goles': 12, 'puntos velocidad': 8,
'puntos asistencia': 2, 'puntos precision pase': 6, 'participacion defensiva': 2}
camiseta_5 = {'nombre': 'Harry Maguire', 'goles': 1, 'puntos velocidad': 5,
'puntos asistencia': 1, 'puntos precision pase': 7, 'participacion defensiva': 9}
camiseta_17 = {'nombre': 'Alejandro Garnacho', 'goles': 8, 'puntos velocidad': 7,
'puntos asistencia': 8, 'puntos precision pase': 16, 'participacion defensiva': 0}
camiseta_7 = {'nombre': 'Mason Mount', 'goles': 2, 'puntos velocidad': 6,
'puntos asistencia': 4, 'puntos precision pase': 8, 'participacion defensiva': 1}
numeros_camisetas = ['8', '11', '5', '17', '7']
lista_camisetas = [camiseta_8, camiseta_11, camiseta_5, camiseta_17, camiseta_7]


# Función jugador más velocidad
def jugador_masrapido():
velocidades = []
for jugador in lista_camisetas:
velocidades.append(jugador['puntos velocidad'])
mas_rapido = max(velocidades)
indice = velocidades.index(mas_rapido)
print(f'El jugador más rapido es {lista_camisetas[indice]['nombre']}')
print(f'Su velocidad es: {mas_rapido}')
input('Presione cualquier tecla para volver al menú')


# Función jugador con más goles
def jugador_masgoles():
goles = []
for jugador in lista_camisetas:
goles.append(jugador['goles'])
mas_goles = max(goles)
indice = goles.index(mas_goles)
print(f'El jugador con más goles es {lista_camisetas[indice]['nombre']}')
print(f'Su cantidad de goles es: {mas_goles}')
input('Presione cualquier tecla para volver al menú')


# Función jugador con más asistencias
def jugador_masasistencias():
asistencias = []
for jugador in lista_camisetas:
asistencias.append(jugador['puntos asistencia'])
mas_asistencias = max(asistencias)
indice = asistencias.index(mas_asistencias)
print(f'El jugador con más asistencias es {lista_camisetas[indice]['nombre']}')
print(f'Su cantidad de asistencias es: {mas_asistencias}')
input('Presione cualquier tecla para volver al menú')


# Función jugador con más precisión de pase
def jugador_precisionpase():
pases = []
for jugador in lista_camisetas:
pases.append(jugador['puntos precision pase'])
mas_pases = max(pases)
indice = pases.index(mas_pases)
print(f'El jugador con más precisión de pase es {lista_camisetas[indice]['nombre']}')
print(f'Su puntaje en precisión de pases es: {mas_pases}')
input('Presione cualquier tecla para volver al menú')


# Función jugador con más participación defensiva
def jugador_defensivo():
defensas = []
for jugador in lista_camisetas:
defensas.append(jugador['participacion defensiva'])
mas_defensas = max(defensas)
indice = defensas.index(mas_defensas)
print(f'El jugador con mayor participación defensiva es {lista_camisetas[indice]['nombre']}')
print(f'Su puntaje en participación defensiva es: {mas_defensas}')
input('Presione cualquier tecla para volver al menú')


# Función de revisión del jugador
def revision_jugador():
while True:
print('*' * 50)
print('Numeros de camiseta de jugadores:')
print(', '.join(numeros_camisetas))
try:
accion = input('Elige un número de camiseta: ')
indice = numeros_camisetas.index(accion)
datos = lista_camisetas[indice]
except ValueError:
system('cls')
print('Error, elige una opción correcta')
else:
system('cls')
for key, value in datos.items():
print(f'{key.capitalize()}: {value}')
input('Presione cualquier tecla para volver al menu')
return


# Función comparación
def comparacion():
while True:
print('*' * 50)
print('Elige a 2 jugadores a comparar')
print('Numeros de camiseta de jugadores:')
print(', '.join(numeros_camisetas))
try:
accion1 = input('Elige al primer jugador: ')
indice1 = numeros_camisetas.index(accion1)
accion2 = input('Elige al segundo jugador: ')
indice2 = numeros_camisetas.index(accion2)
except ValueError:
system('cls')
print('Error, ingrese los valores correctos')
else:
system('cls')
datos_jugador1 = lista_camisetas[indice1]
datos_jugador2 = lista_camisetas[indice2]
for key, value in datos_jugador1.items():
print(f'{key.capitalize()} : {value}')
print('')
for key, value in datos_jugador2.items():
print(f'{key.capitalize()}: {value}')
input('Presione cualquier tecla para volver al menu')
return


# Función menú
def menu():
while True:
print('*' * 50)
print('Bienvenido al programa de jugadores del Manchester United')
print('[1] Ver datos de jugador\n[2] Comparar 2 jugadores\n[3] Ver jugador con más goles\n'
'[4] Ver jugador con más velocidad\n[5] Ver jugador con más asistencias\n'
'[6] Ver jugador con más precisión de pase\n[7] Ver jugador más defensivo\n[8] Terminar programa')
try:
accion = input('Elige una opción: ')
['1', '2', '3', '4', '5', '6', '7', '8'].index(accion)
except ValueError:
system('cls')
print('Error, Elige una opción valida')
else:
return accion


# Función main
def main():
validacion = True
while validacion:
system('cls')
accion = menu()
if accion == '1':
system('cls')
revision_jugador()
continue
elif accion == '2':
system('cls')
comparacion()
continue

elif accion == '3':
system('cls')
jugador_masgoles()
continue

elif accion == '4':
system('cls')
jugador_masrapido()
continue

elif accion == '5':
system('cls')
jugador_masasistencias()
continue

elif accion == '6':
system('cls')
jugador_precisionpase()
continue

elif accion == '7':
system('cls')
jugador_defensivo()
continue

else:
system('cls')
print('El programa ha sido finalizado')
validacion = False


if __name__ == '__main__':
main()
Loading