CompSci Blogs

August 2023 to June 2024

View the Project on GitHub IshanCornick/new_student

24 August 2023

Python Quiz

Python Quiz

Welcome to the Python quiz! You will be asked a series of questions to test your knowledge of Python programming. Let’s get started!

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/questions * 100)//1) + "% of questions right")
Hello, Ishan running /usr/local/opt/python@3.11/bin/python3.11
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?
jh is incorrect!
Question: What command is used to evaluate correct or incorrect response in this example?
h is incorrect!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
 is incorrect!
Ishan you scored 0.0% of questions right

Python Quiz

Welcome to the Python quiz! You will be asked a series of questions to test your knowledge of Python programming. Let’s get started!

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/questions * 100)//1) + "% of questions right")
Hello, Ishan running /usr/local/opt/python@3.11/bin/python3.11
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?
jh is incorrect!
Question: What command is used to evaluate correct or incorrect response in this example?
h is incorrect!
Question: Each 'if' command contains an '_________' to determine a true or false condition?
 is incorrect!
Ishan you scored 0.0% of questions right