Original Quiz by Mr. Mortenson

Below shows the initial code created by Mr. Mortenson in Hello to Python.

import getpass, sys

def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg

questions = 3
correct = 0

print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
question_with_response("Are you ready to take a test?")

rsp = question_with_response("What command is used to include other functions that were previously developed?")
if rsp == "import":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("What command is used to evaluate correct or incorrect response in this example?")
if rsp == "if":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
if rsp == "expression":
    print(rsp + " is correct!")
    correct += 1
else:
    print(rsp + " is incorrect!")

print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions))
Hello, root running /bin/python3
You will be asked 3 questions.
Question: Are you ready to take a test?
Question: What command is used to include other functions that were previously developed?
yes is incorrect!
Question: What command is used to evaluate correct or incorrect response in this example?
if is correct!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
expression is correct!
root you scored 2/3
def question_and_answer(prompt):
    print("Question: " + prompt)
    msg = input()
    print("Answer: " + msg)

question_and_answer("Name the Python output command mentioned in this lesson?")
question_and_answer("If you see many lines of code in order, what would College Board call it?")
question_and_answer("Describe a keyword used in Python to define a function?")
Question: Name the Python output command mentioned in this lesson?
Answer: sequence
Question: If you see many lines of code in order, what would College Board call it?
Answer: sequence
Question: Describe a keyword used in Python to define a function?
Answer: sequence

Changes Made by Me

Compared to my friend Alex Lu's quiz, this will be very lacking, but I think that this is a good representation of my current abilities.

import getpass, sys

def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg

questions = 3
correct = 0
skipped = 0

print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
rsp = question_with_response("Are you ready to take a test? Answer 'yes' or 'no'")
if rsp == "yes":
    print("good luck")
if rsp == "no":
    print("too bad")

rsp = question_with_response("What command is used to include other functions that were previously developed?")
if rsp == "import":
    print(rsp + " is correct!")
    correct += 1
elif rsp == "skip":
    print("skipping question")
    skipped += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("What command is used to evaluate correct or incorrect response in this example?")
if rsp == "if":
    print(rsp + " is correct!")
    correct += 1
elif rsp == "skip":
    print("skipping question")
    skipped += 1
else:
    print(rsp + " is incorrect!")

rsp = question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?")
if rsp == "expression":
    print(rsp + " is correct!")
    correct += 1
elif rsp == "skip":
    print("skipping question")
    skipped += 1
else:
    print(rsp + " is incorrect!")

print(getpass.getuser() + " you scored " + str(correct) + "/" + str(questions) + ", with " + str(skipped) + " skipped questions")
Hello, chewyboba10 running /bin/python3
You will be asked 3 questions.
Question: Are you ready to take a test? Answer 'yes' or 'no'
too bad
Question: What command is used to include other functions that were previously developed?
skipping question
Question: What command is used to evaluate correct or incorrect response in this example?
if is correct!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
expression is correct!
chewyboba10 you scored 2/3, with 0 skipped questions

Getting Rid of Repeating Code

It will take a long time to add these lines of code multiple times, so I'll try to reduce the amount I make when creating more questions.

import getpass, sys

questions = 10
correct = 0
skipped = 0

def question_with_response(question, answer):
    print("Question: " + question)
    msg = input()
    if msg == answer:
        print(msg + " is correct")
        global correct
        correct += 1
    elif msg == "skip":
        print("Question has been skipped")
        global skipped
        skipped += 1
    else:
        print(msg + " is incorrect")

def percentage(right, wrong):
    percentage = 100 * float(right)/float(wrong)
    return str(percentage) + "%" 

print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
print("Are you ready to take a test?")
rsp = input()
if rsp == "yes":
    print("Great! Good luck!")
if rsp == "no":
    print("too bad")

question_with_response("Name the Python output command mentioned in this lesson?", "print")
question_with_response("If you see many lines of code in order, what would College Board call it?", "sequence")
question_with_response("Describe a keyword used in Python to define a function?", "def")
question_with_response("What command is used to evaluate correct or incorrect response in this quiz?", "if")
question_with_response("Each 'if' command contains an '_________' to determine a true or false condition?", "expression")
question_with_response("What is an input to a function or method called?", "parameter")
question_with_response("If Input is data the computer receives, what is the data that the computer sends back?", "output")
question_with_response("What is a reusable block of code called?", "function")
question_with_response("What operator is used for string concatenation in Python?", "+")
question_with_response("Which function can be used to turn numbers turned into string in Python?", "str() function")

print("Congratulations " + getpass.getuser() + "! You got " + percentage(correct, questions) + " and skipped " + str(skipped) + " questions!")
Hello, chewyboba10 running /bin/python3
You will be asked 10 questions.
Are you ready to take a test?
too bad
Question: Name the Python output command mentioned in this lesson?
print is correct
Question: If you see many lines of code in order, what would College Board call it?
sequence is correct
Question: Describe a keyword used in Python to define a function?
Question has been skipped
Question: What command is used to evaluate correct or incorrect response in this quiz?
if is correct
Question: Each 'if' command contains an '_________' to determine a true or false condition?
expression is correct
Question: What is an input to a function or method called?
parameter is correct
Question: If Input is data the computer receives, what is the data that the computer sends back?
output is correct
Question: What is a reusable block of code called?
idk is incorrect
Question: What operator is used for string concatenation in Python?
+ is correct
Question: Which function can be used to turn numbers turned into string in Python?
str() function is correct
Congratulations chewyboba10! You got 80.0% and skipped 1 questions!

I am satisfied with how this turned out! Please comment if there is any problems or things I can work on.