-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6af14f7
commit e4b8853
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# ejercicio 15 | ||
# ejercicio 15 | ||
|
||
cuenta_ahorros = float(input("Introduce la cantidad de dinero que tienes: ")) | ||
|
||
intereses = 0.04 | ||
|
||
ahorros_primer_año = cuenta_ahorros * (1 + intereses) | ||
ahorros_segundo_año = ahorros_primer_año * (1 + intereses) | ||
ahorros_tercer_año = ahorros_segundo_año * (1 + intereses) | ||
|
||
print(f"Ahorros tras el primer año: {ahorros_primer_año:.2f} ") | ||
print(f"Ahorros tras el segundo año: {ahorros_segundo_año:.2f} ") | ||
print(f"Ahorros tras el tercer año: {ahorros_tercer_año:.2f} ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# ejercicio 16 | ||
|
||
precio_habitual = 3.49 | ||
|
||
descuento = 0.60 | ||
|
||
def main(): | ||
|
||
try: | ||
num_barras = int(input("Introduce el número de barras que no son del día: ")) | ||
if num_barras < 0: | ||
print("El numero de barras no puede ser negativo. ") | ||
return | ||
|
||
precio_con_descuento = precio_habitual * (1 - descuento) | ||
|
||
coste_total = precio_con_descuento * num_barras | ||
|
||
print(f"El precio de la barra de pan habitual: {precio_habitual:.2f}€ ") | ||
print(f"El precio de descuento por no ser fresca: {descuento * 100}% ") | ||
print(f"El Precio de la barra de pan con descuento: {coste_total:.2f}€ ") | ||
|
||
except ValueError: | ||
print("Por favor, introduce un número válido. ") | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
|