-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuizGame.py
47 lines (42 loc) · 1.4 KB
/
QuizGame.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
# ================= Problem Description =================
# This script implements a simple computer quiz game.
# The user is prompted to play a quiz where they answer a question about computer hardware.
#
# 1. Greets the user and asks if they want to play.
# 2. If the user responds with "yes", the quiz starts; otherwise, the program exits.
# 3. Asks the user a question about what CPU stands for.
# 4. Evaluates the user's answer and updates the score based on correctness.
# 5. Displays the final score and ends the quiz.
#
# ================= Input =================
# - User's response to the initial prompt ("yes" or any other response).
# - User's answer to the quiz question.
#
# ================= Output =================
# - Feedback on the correctness of the answer.
# - The final score after the quiz.
#
# Example:
# Input:
# Do you want to play? yes
# What does CPU stand for? central processing unit
# Output:
# Correct
# Your score is 1
# END
# =========================================================
print("Welcome to my computer quiz!")
playing = input("Do you want to play? ")
if playing.lower() != "yes":
quit()
else:
print("Ok, let's play!")
score = 0
answer = input("What does CPU stand for? ")
if answer.lower() == "central processing unit":
print("Correct")
score += 1
else:
print("Incorrect")
print(f"Your score is {score}")
print("END")