import getpass, sys
def question_and_answer(prompt):
    print("Question:" +prompt)
    msg = input("Question:" +prompt)
    print("Answer:" +msg)
## defines the format of how the question will be asked
def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input("Question: " + prompt)
    return msg
    
question_list = [   ## shows the list of questions that will be asked on the quiz
    "What command is used to include other functions that were previously developed?",
    "What command is used to evaluate correct or incorrect response in this example?",
    "Each 'if' command contains an '_________' to determine a true or false condition?",
    "What is the term used to describe a set of two or more lines of code?",
    "What is a key word used in Python to describe a function?",
    "What is the name of the library that we are importing this function from?"
]

answer_list = [
    "import",
    "if",
    "expression",
    "sequence",
    "def",
    "os"
]
## the number of questions being asked is equal to how many there are on the list
questions = len(question_list)
correct = 0

## This is what the user will be prompted with before taking the quiz
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?")

## If the user types in yes as their answer, the quiz will begin
if rsp == "yes":

    print("You said yes, so let's get started!")
 ## Depending on the question, if the answer the user inputted matches one of the answers on the list, they will get a message saying they are correct.
    for i in range(len(question_list)):
        rsp = question_with_response(question_list[i])
        if rsp == answer_list[i]:
            print(rsp + " is correct! Yay!")
            correct += 1
## If the answer the user inputted doesn't match any of the answers on the list (again depending on question), they will get a message saying they are wrong.
        else:
            print(rsp + " is incorrect! Sorry!")

## After completing the quiz, the user will get their score out of 6 and the percentage
    print(getpass.getuser() + " you scored " + str(correct) +"/" + str(questions) + " which is " + str((correct / questions) * 100) + "%")
## If the user types in no to not being ready, the user will have this message
else:
    print("You said no, so come back when you're ready!")
Hello, root running /bin/python3
You will be asked 6 questions.
Question: Are you ready to take a test?
You said yes, so let's get started!
Question: What command is used to include other functions that were previously developed?
import is correct! Yay!
Question: What command is used to evaluate correct or incorrect response in this example?
m is incorrect! Sorry!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
k is incorrect! Sorry!
Question: What is the term used to describe a set of two or more lines of code?
l is incorrect! Sorry!
Question: What is a key word used in Python to describe a function?
l is incorrect! Sorry!
Question: What is the name of the library that we are importing this function from?
os is correct! Yay!
root you scored 2/6 which is 33.33333333333333%
qa_list = []
qa_list.append({
    "Question": "What command is used to include other functions that were previously developed?",
    "Answer": "import"
})

score = 0

for q in qa_list:
    response = input(q["Question"])
    if response == q["Answer"]:
        score = score + 1