Please draw the correct flowchart for this game ?
Please draw the correct flowchart for this game ?
# Function to display question and answer
def new_game():
guesses = []
Right_guesses = 0
question_num = 1
num = 1
for key in questions:
print("\n------------------------- \n")
print("Question " + str(num) + "\n" )
num += 1
print(key)
for i in options[question_num-1]:
print(i)
guess = input("\nAnswer (A, B, C, or D): ")
guess = guess.upper()
guesses.append(guess)
Right_guesses += check_answer(questions.get(key), guess)
question_num += 1
display_score(Right_guesses, guesses)
# -------------------------
# Function to check answer
def check_answer(answer, guess):
if answer == guess:
print("\nYour Answer Correct!")
return 1
else:
print("\nYour Answer Wrong!")
return 0
# -------------------------
# Function to display score
def display_score(Right_guesses, guesses):
print("\n-------------------------")
print( "\t" + name.capitalize() + " Result")
print("-------------------------")
print( "\n" + name.capitalize() + " Answers: \n", end="")
for i in questions:
print(questions.get(i), end=" ")
print()
print("\n" + name.capitalize() + " Guesses: \n", end="")
for i in guesses:
print(i, end=" ")
print()
score = int((Right_guesses/len(questions))*100)
print("\n" + name.capitalize() + " Score: "+str(score)+"%")
if score >= 70 :
print ("\nCongratulation " + name.capitalize() + "!!")
else:
print ("\nYour Failed, Try Again")
# -------------------------
# Function to user want play again
def play_again():
response = input("\nDo you want to play again? (yes or no): ")
response = response.upper()
if response == "YES":
return True
else:
return False
# -------------------------
# List Question and Answer
questions = {
"The term “Islam” means?: ": "A",
"Muslims believe that Muhammad was?: ": "D",
"Which of the following is an essential part of Islamic belief?: ": "D",
"The chapters of the Qur'an are known as?: ": "A"
}
options = [["A. submission", "B. peace", "C. fortitude", "D. thankfulness"],
["A. the first prophet", "B. the final prophet", "C. one of many prophets", "D. both b and c"],
["A. The belief in the oneness of God", "B. The belief in the Day of Judgment", "C. The belief in prophets", "D. All of the above"],
["A. surahs","B. sunnahs", "C. shari'ah", "D. sufis"]]
# -------------------------
# Main function
print ("-------------------------")
print (" Welcome To Our Games ")
print ("-------------------------")
name = input("\nWhat is your name? : ")
response = input("\nDo you want to play games? (yes or no): ")
response = response.upper()
if response == "YES":
new_game()
while play_again():
new_game()
print("\nThank You and See You Again !!")

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images









