Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 30, 2020 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/9404e5306290375c52986aa96188643e to your computer and use it in GitHub Desktop.
Save parzibyte/9404e5306290375c52986aa96188643e to your computer and use it in GitHub Desktop.
"""
____ _____ _ _ _
| _ \ | __ \ (_) | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___|
__/ | __/ |
|___/ |___/
Blog: https://parzibyte.me/blog
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/
Contacto: https://parzibyte.me/blog/contacto/
Copyright (c) 2020 Luis Cabrera Benito
Licenciado bajo la licencia MIT
El texto de arriba debe ser incluido en cualquier redistribución
"""
PRECIO_POR_NOCHE = 70000
TIPO_ESTADIA_SOLO_DESAYUNO = "1"
TIPO_ESTADIA_TODO_INCLUIDO = "2"
def calcular(codigo):
fecha_ingreso = codigo[0:8]
anio = fecha_ingreso[0:4]
mes = fecha_ingreso[4:6]
dia = fecha_ingreso[6:8]
fecha_sin_anio = mes + dia
numero_noches = int(codigo[8:10])
habitacion = int(codigo[10:13])
servicios = codigo[13:14]
veces_alojado = int(codigo[14:])
precio_alojamiento = PRECIO_POR_NOCHE * numero_noches
aumento = 0
if habitacion % 2 == 0:
aumento += precio_alojamiento * 0.1
if servicios == TIPO_ESTADIA_TODO_INCLUIDO:
aumento += precio_alojamiento * 0.15
if ("1220" <= fecha_sin_anio <= "0305") or ("0910" <= fecha_sin_anio <= "0920"):
aumento += precio_alojamiento * 0.2
descuento = (precio_alojamiento * 0.03) * veces_alojado
total = precio_alojamiento - descuento + aumento
print(f"Fecha de ingreso: {dia}-{mes}-{anio}")
print(f"Tipo de estadía: {servicios}")
print(f"Tiempo de estadía: {numero_noches} días")
print(f"Número de habitación: {habitacion}")
print(f"Número de veces que ha alojado: {veces_alojado}")
print(f"Valor de estadía completa: ${total}")
def main():
codigo = input("Ingresa el código del pasajero: ")
calcular(codigo)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment