-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPrograma 3_20.py
More file actions
27 lines (26 loc) · 1.01 KB
/
Programa 3_20.py
File metadata and controls
27 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
"""
@author: guardati
Solución del problema 3.20
Cacula e imprime el total a pagar en un hotel, de acuerdo al tipo de
habitación ocupada y a la cantidad de días de hospedaje.
"""
dias_hospedaje = int(input('Ingrese el total de días de la estadía: '))
tipo_habitacion = input('Ingrese el tipo de habitación ocupada: ')
tipo_habitacion = tipo_habitacion.upper()
if tipo_habitacion == 'S':
precio = 1500
elif tipo_habitacion == 'D':
precio = 2100
elif tipo_habitacion == 'T':
precio = 2700
elif tipo_habitacion == 'F':
precio = 3500
else:
precio = -1 # Si se ingresó un tipo equivocado de habitación.
''' Si precio es -1 se obtendrá un valor negativo el cual se imprimirá
y deberá interpretarse como una alarma de que hubo un error en los datos.
En otras secciones y capítulos se verán mejores alternativas para manejar
este tipo de errores. '''
total_pagar = precio * dias_hospedaje
print(f'\nEl total a pagar en el hotel = ${total_pagar:.2f}')