Explain the flow of this program ?   def new_game():     guesses = []     correct_guesses = 0     question_num = 1     for key in questions:         print("-------------------------")         print(key)         for i in options[question_num-1]:             print(i)         guess = input("Enter (A, B, C, or D): ")         guess = guess.upper()         guesses.append(guess)         correct_guesses += check_answer(questions.get(key), guess)         question_num += 1     display_score(correct_guesses, guesses) # ------------------------- def check_answer(answer, guess):     if answer == guess:         print("CORRECT!")         return 1     else:         print("WRONG!")         return 0 # ------------------------- def display_score(correct_guesses, guesses):     print("-------------------------")     print("RESULTS")     print("-------------------------")     print("Answers: ", end="")     for i in questions:         print(questions.get(i), end=" ")     print()     print("Guesses: ", end="")     for i in guesses:         print(i, end=" ")     print()     score = int((correct_guesses/len(questions))*100)     print("Your score is: "+str(score)+"%") # ------------------------- def play_again():     response = input("Do you want to play again? (yes or no): ")     response = response.upper()     if response == "YES":         return True     else:         return False # ------------------------- questions = {  "Who created Python?: ": "A",  "What year was Python created?: ": "B",  "Python is tributed to which comedy group?: ": "C",  "Is the Earth round?: ": "A" } options = [["A. Guido van Rossum", "B. Elon Musk", "C. Bill Gates", "D. Mark Zuckerburg"],           ["A. 1989", "B. 1991", "C. 2000", "D. 2016"],           ["A. Lonely Island", "B. Smosh", "C. Monty Python", "D. SNL"],           ["A. True","B. False", "C. sometimes", "D. What's Earth?"]] new_game() while play_again():     new_game() print("Byeeeeee!") # -------------------------

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Explain the flow of this program ?

 

def new_game():

    guesses = []
    correct_guesses = 0
    question_num = 1

    for key in questions:
        print("-------------------------")
        print(key)
        for i in options[question_num-1]:
            print(i)
        guess = input("Enter (A, B, C, or D): ")
        guess = guess.upper()
        guesses.append(guess)

        correct_guesses += check_answer(questions.get(key), guess)
        question_num += 1

    display_score(correct_guesses, guesses)

# -------------------------
def check_answer(answer, guess):

    if answer == guess:
        print("CORRECT!")
        return 1
    else:
        print("WRONG!")
        return 0

# -------------------------
def display_score(correct_guesses, guesses):
    print("-------------------------")
    print("RESULTS")
    print("-------------------------")

    print("Answers: ", end="")
    for i in questions:
        print(questions.get(i), end=" ")
    print()

    print("Guesses: ", end="")
    for i in guesses:
        print(i, end=" ")
    print()

    score = int((correct_guesses/len(questions))*100)
    print("Your score is: "+str(score)+"%")

# -------------------------
def play_again():

    response = input("Do you want to play again? (yes or no): ")
    response = response.upper()

    if response == "YES":
        return True
    else:
        return False
# -------------------------


questions = {
 "Who created Python?: ": "A",
 "What year was Python created?: ": "B",
 "Python is tributed to which comedy group?: ": "C",
 "Is the Earth round?: ": "A"
}

options = [["A. Guido van Rossum", "B. Elon Musk", "C. Bill Gates", "D. Mark Zuckerburg"],
          ["A. 1989", "B. 1991", "C. 2000", "D. 2016"],
          ["A. Lonely Island", "B. Smosh", "C. Monty Python", "D. SNL"],
          ["A. True","B. False", "C. sometimes", "D. What's Earth?"]]

new_game()

while play_again():
    new_game()

print("Byeeeeee!")

# -------------------------

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education