forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouredev.py
86 lines (68 loc) · 2.83 KB
/
mouredev.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import random
# gryffindor: valor
# hufflepuff: lealtad
# ravenclaw: sabiduría
# slytherin: ambición
class HatQuestion:
def __init__(self, question, answers):
self.question = question
self.answers = answers
def get_answer():
answer = input("Responde 1, 2, 3 o 4: ")
if answer == "1" or answer == "2" or answer == "3" or answer == "4":
return int(answer)
return get_answer()
print("Hola, soy el \"Sombrero Seleccionador\"\nTendrás que responder cinco preguntas para ayudarme a descubrir tu casa de Hogwarts.\n")
hat_questions = [HatQuestion("¿Cómo te definirías?", [
("1. Valiente", "gryffindor"),
("2. Leal", "hufflepuff"),
("3. Sabio", "ravenclaw"),
("4. Ambicioso", "slytherin")]),
HatQuestion("¿Cuál es tu clase favorita?", [
("1. Vuelo", "gryffindor"),
("2. Pociones", "ravenclaw"),
("3. Defensa contra las artes oscuras", "slytherin"),
("4. Animales fantásticos", "hufflepuff")]),
HatQuestion("¿Dónde pasarías más tiempo?", [
("1. Invernadero", "hufflepuff"),
("2. Biblioteca", "ravenclaw"),
("3. En la sala común", "slytherin"),
("4. Explorando", "gryffindor")]),
HatQuestion("¿Cuál es tu color favorito?", [
("1. Rojo", "gryffindor"),
("2. Azul", "ravenclaw"),
("3. Verde", "slytherin"),
("4. Amarillo", "hufflepuff")]),
HatQuestion("¿Cuál es tu mascota?", [
("1. Sapo", "ravenclaw"),
("2. Lechuza", "gryffindor"),
("3. Gato", "hufflepuff"),
("4. Serpiente", "slytherin")])]
houses = {
"gryffindor": 0,
"hufflepuff": 0,
"ravenclaw": 0,
"slytherin": 0
}
for hat_question in hat_questions:
print(hat_question.question)
for hat_answers in hat_question.answers:
print(hat_answers[0])
house = hat_question.answers[get_answer() - 1][1]
houses[house] += 1
print()
selected_house = []
max_points = 0
for house, points in houses.items():
if points > max_points:
selected_house.clear()
selected_house.append(house)
max_points = points
elif points == max_points:
selected_house.append(house)
max_points = points
if len(selected_house) == 1:
print(f"Lo tengo claro... ¡{selected_house[0].capitalize()}!")
else:
print(
f"Ha estado complicado... ¡{random.choice(selected_house).capitalize()}!")