Python Quiz
Quiz to test your Python knowledge
art = """
.-_'''-. .-------. ____ _______ .-''-. _ _ .-'''-. ,-----. ___ _ .-./`) ____..--'
'_( )_ \ | _ _ \ .' __ `. / __ \ .'_ _ \ ( ' ) / _ \ .' .-, '. .' | | |\ .-.')| |
|(_ o _)| ' | ( ' ) | / ' \ \ | ,_/ \__) / ( ` ) '(_{;}_)(`' )/`--' / ,-.| \ _ \ | .' | |/ `-' \| .-' '
. (_,_)/___| |(_ o _) / |___| / |,-./ ) . (_ o _) | (_,_)(_ o _). ; \ '_ / | :.' '_ | | `-'`"`|.-'.' /
| | .-----.| (_,_).' __ _.-` |\ '_ '`) | (_,_)___| (_,_). '. | _`,/ \ _/ |' ( \.-.| .---. / _/
' \ '- .'| |\ \ | |.' _ | > (_) ) __' \ .---. .---. \ : : ( '\_/ \ ;' (`. _` /| | | .'._( )_
\ `-'` | | | \ `' /| _( )_ |( . .-'_/ )\ `-' / \ `-' | \ `"/ \ ) \| (_ (_) _) | |.' (_'o._)
\ / | | \ / \ (_ o _) / `-'`-' / \ / \ / '. \_/``"/) )\ / . \ / | || (_,_)|
`'-...-' ''-' `'-' '.(_,_).' `._____.' `'-..-' `-...-' '-----' `-' ``-'`-'' '---'|_________|
"""
print("Hi")
print(art)
print("Welcome to Grace's Quiz!")
start = input("Do you want to take Grace's Quiz?")
score = 0
def ask_question(question_num, question, answer):
"""Asks question and determines if """
print(f"Question {question_num}: {question}")
user_answer = ask_for_answer()
is_answer_right(user_answer, answer)
def ask_for_answer():
"""Asks for an input from the user and returns user answer"""
answer = input().lower()
print(answer)
return answer
def is_answer_right(user_answer, answer):
"""Inputs user answer and actual answer and adds to score if answer is right"""
global score
if user_answer == answer:
score += 1
print(f"Good job! The answer is {answer}!")
else:
print(f"Sorry, incorrect π’. The right answer was {answer}.")
print(f"Your score is {score}.")
if start.lower() == "yes" or start.lower() == "y":
print("Great! Good luck π")
else:
print("Take a mindful minute. You got this :)")
print("This game will have 5 questions!")
#Asks questions
ask_question(1, "What command defines a function or method?", "def")
ask_question(2, "What conditionally executes a block of code, along with else and elif?", "if statement")
ask_question(3, "What does a jupyter notebook end in?", "ipynb")
ask_question(4, "What is style of programming characterized by the identification of classes of objects closely linked with the methods?", "object oriented programming")
ask_question(5, "What is the text at the front of a markdown post called?", "front matter")
#Prints a message depending on what score user got
if score == 5:
print("Wow! You know your stuff! Keep up the good work! π€")
if score == 4:
print("Almost! Try again.")
if score <= 3:
print("You're average π ")