username = input("Hello, enter your name here: ");#asks for user name
print("Hello " + username + ".");#greeting
questions={"What command is used to include other functions that were previously developed?":"import",
"What command is used to evaluate correct or incorrect response in this example?":"if",
"Each 'if' command contains an '_________' to determine a true or false condition?":"expression",
"Name the Python output command mentioned in this lesson?":"print",
"Describe a keyword used in Python to define a function?":"def",
"What is the keyword to get user input?":"input"
}#creates a dictionary with the key being the question and the value being the answer
def quiz():
points=0;#number of questions correct
num=0;#number of questions total
for i in questions:#loops to ask all the questions inside the dictionary
answer = input("Question: " + i);#asks user for answer
if(answer.lower() == questions[i]):#if guess is equal to answer...
print(answer.lower() + " is Correct!");#print correct and add 1 point
points+=1;
else:
print(answer.lower() + " is Incorrect.");#print incorrect
num+=1;#add 1 to the total num of questions
return("Your score is " + str(points) + "/" + str(num) +".(" +str(int((points/num)*100))+"%)");
print(quiz());
Hello Yeongsu.
import is Correct!
if is Correct!
expression is Correct!
print is Correct!
def is Correct!
input is Correct!
Your score is 6/6.(100%)