Skip to content

Commit d151ac1

Browse files
authored
Merge pull request #161 from lorenzohanssens/main
Added a simple customizable quizzing app
2 parents 8c83e97 + 4f4b85e commit d151ac1

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Q/Quiz-test.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
words = {
2+
}
3+
4+
newWord = ""
5+
newDefintion = ""
6+
print("Welcome to a quizzing app! Let's start by adding words to our vocabulary, to start quizzing enter a new word with the name \"stop!\"")
7+
while(newWord != "stop!"):
8+
newWord = input("What is the word?: ")
9+
if newWord == "stop!": break
10+
newDefintion = input(f"What is the definition of {newWord}?: ")
11+
words[newWord] = newDefintion
12+
13+
14+
redo = []
15+
score = 0
16+
17+
18+
def checkWord(word, uInput):
19+
if(uInput.lower() == words.get(word).lower()): return 1
20+
elif(uInput == "skip" or uInput == None or uInput == ""): return 0
21+
else: return -1
22+
23+
print("welcome")
24+
25+
26+
27+
for word in words:
28+
userInput = input(f"What is the definition of {word}? (type skip to skip): ").lower()
29+
result = checkWord(word, userInput)
30+
match result:
31+
case -1:
32+
print(f"Wrong answer. The answer was: {words.get(word)}")
33+
case 0:
34+
print(f"Skipped! The answer was: {words.get(word)}")
35+
redo.append(word)
36+
case 1:
37+
score += 1
38+
print("correct +1")
39+
40+
if redo:
41+
for skip in redo:
42+
userInput = input(f"What is the definition of {skip}?: ").lower()
43+
result = checkWord(skip, userInput)
44+
match result:
45+
case -1:
46+
print(f"Wrong answer. The answer was: {words.get(skip)}")
47+
case 0:
48+
print(f"Wrong answer. The answer was: {words.get(skip)}")
49+
case 1:
50+
score += 1
51+
print("correct +1")
52+
53+
print(f"Your score is: {score}/{len(words)}")
54+

0 commit comments

Comments
 (0)