-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
164 lines (144 loc) · 5.03 KB
/
main.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import random
import time
BLACK = '\033[30m'
RED = '\033[31m'
GREEN = '\033[32m'
YELLOW = '\033[33m'
BLUE = '\033[34m'
MAGENTA = '\033[35m'
CYAN = '\033[36m'
WHITE = '\033[37m'
RESET = '\033[39m'
print(MAGENTA + "Bienvenido a mi trivia sobre desarrollo de software" + RESET)
print(CYAN + "Pondremos a prueba tus conocimientos" + RESET)
score = random.randint(1, 10)
good = 10
bad = 5
starting_trivia = True
attempts = 0
attempts_score_list = []
options_list = []
options_1 = [
"a) Hyper text meta language", "b) Hype Talent More Language",
"c) HyperText Markup Language", "d) NA"
]
options_list.append(options_1)
options_2 = ["a) Javascript", "b) Golang", "c) PHP", "d) HTML"]
options_list.append(options_2)
options_3 = [
"a) Trabaja con bases de datos directamente",
"b) El lenguaje se ejecuta en el servidor",
"c) Utiliza un framework popular llamado REACT.JS", "d) NA"
]
options_list.append(options_3)
options_4 = ["a) 1989", "b) 1988", "c) 1600", "d) 2000"]
options_list.append(options_4)
def showOptions(list):
for e in list:
print(GREEN + e + RESET)
def showScore(score):
time.sleep(1)
print(YELLOW + "Su score hasta ahora es", score, "\n" + RESET)
time.sleep(2)
def isCorrect(answer, correct_aswer):
if answer != correct_aswer:
print(RED + "Incorrecto ", nombre, "la respuesta es ",
correct_aswer + RESET)
return -bad
else:
print(BLUE + "Correcto ", nombre, "la respuesta es ",
correct_aswer + RESET)
return good
def showAttemptsScoreList():
print("Sus puntajes son: \n")
for number in range(0, len(attempts_score_list), +1):
time.sleep(1)
print("Intento nro: ", number + 1, "=> ", attempts_score_list[number])
print(
CYAN + "Tu puntaje inicial es ", score,
"\nEl juego comenzara en 5s, veremos con cuanto puntaje terminas.." +
RESET)
for x in range(0, 3, +1):
time.sleep(1)
nombre = input("Ingresa tu nombre: ")
print(
BLUE + "\nHola", nombre,
"responde las siguientes preguntas escribiendo la letra de la alternativa y presionando 'Enter' para enviar tu respuesta:\n"
+ RESET)
while starting_trivia == True:
attempts += 1
print("\nIntento número:", attempts)
input("Presiona Enter para continuar\n")
# Pregunta 1
print(YELLOW + "1) ¿Qué significa HTML?" + RESET)
showOptions(options_list[0])
respuesta_1 = input("\nTu respuesta: ")
while respuesta_1 not in ("a", "b", "c", "d", "x"):
respuesta_1 = input(
"Debe responder alguna de estas alternativas a,b,c,d, ingresa nuevamente tu respuesta: "
)
if respuesta_1 == "x":
print("Respuesta secret ", nombre, "la respuesta es genial y secreta")
score += 1200
else:
score += isCorrect(respuesta_1, "c")
showScore(score)
# Pregunta 2
print(YELLOW + "2) ¿Cuál no es un lenguaje de programación?" + RESET)
showOptions(options_list[1])
respuesta_2 = input("\nTu respuesta: ")
while respuesta_2 not in ("a", "b", "c", "d"):
respuesta_2 = input(
"Debes responder a, b, c o d. Ingresa nuevamente tu respuesta: ")
score += isCorrect(respuesta_2, "d")
showScore(score)
# Pregunta 3
print(YELLOW + "3) ¿Cuál es una caracteristica del desarrollo frontend?" +
RESET)
showOptions(options_list[2])
respuesta_3 = input("\nTu respuesta: ")
while respuesta_3 not in ("a", "b", "c", "d"):
respuesta_3 = input(
"Debes responder a, b, c o d. Ingresa nuevamente tu respuesta: ")
score += isCorrect(respuesta_3, "c")
showScore(score)
# Pregunta 4
print(YELLOW + "4) ¿En que año se creo el lenguaje Python?" + RESET)
showOptions(options_list[3])
respuesta_4 = input("\nTu respuesta: ")
while respuesta_4 not in ("a", "b", "c", "d"):
respuesta_4 = input(
"Debes responder a, b, c o d. Ingresa nuevamente tu respuesta: ")
if respuesta_4 == "b":
print("Masomenos ", nombre, "la respuesta es a")
score += 5
elif respuesta_4 == "c":
print("Disparatado ", nombre, "la respuesta es a")
score = score / 2
elif respuesta_4 == "d":
print("Malo ", nombre, "la respuesta es a")
score -= 5
else:
print("Correcto ", nombre, "la respuesta es a\n")
score = score * 2
time.sleep(3)
#Random Score
for x in range(random.randint(1, 5), random.randint(6, 10), +1):
score = score + x
print("Su score final es", score, "\n")
attempts_score_list.append(score)
time.sleep(1)
print("\n¿Deseas intentar la trivia nuevamente?")
repetir_trivia = input(
"Ingresa 'si' para repetir, o cualquier tecla para finalizar: ").lower(
)
score = 0
if repetir_trivia != "si":
showAttemptsScoreList()
time.sleep(2)
print(YELLOW + "La suma de tu puntaje es", sum(attempts_score_list),
RESET)
time.sleep(1)
print(
f"\nEsperamos, {nombre}, que lo hayas pasado bien, hasta pronto!")
starting_trivia = False