-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht7e01.libros.py
36 lines (28 loc) · 930 Bytes
/
t7e01.libros.py
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
28
29
30
31
32
33
34
35
libro1: dict = {
"título": "El Marciano",
"autor": "Andy Weir",
"editorial": "Nova",
"páginas": 407,
"precio": 20.5
}
print("El autor del libro es", libro1['autor'])
libro2: dict = {}
info: str = "Dune # Frank Herbert # Debolsillo (Pengun Ed.) 784 11.35"
título, autor, resto = info.split("#")
libro2["título"] = título.strip()
libro2["autor"] = autor.strip()
datos: list = resto.split()
libro2["páginas"] = int(datos[-2])
libro2["precio"] = float(datos[-1])
libro2["editorial"] = " ".join(datos[:-2])
print(libro2)
if libro1['páginas'] > libro2['páginas']:
print(f"El libro {libro1['título']} tiene {libro1['páginas']} páginas")
else:
print(f"El libro {libro2['título']} tiene {libro2['páginas']} páginas")
if libro1['precio'] > libro2['precio']:
libro1['precio'] = libro1['precio']*0.95
print(libro1)
else:
libro2['precio'] = libro2['precio']*0.95
print(libro2)