Python Quiz - Basic Concepts!
Put your understanding of basic python concepts to the test!
Hello! Thank you for visiting this page. Here, you will be quizzed on four of the most basic concepts Python has to offered, all of which we reviewed throughout the first 2 weeks of this class. Good luck, and enjoy!
correct = 0 #this represents the total number of questions answered correctly by the test taker
def question(prompt, answer): #this function receives the answer typed in by the user, then whether or not that input was correct
print ("Question: " + prompt) #Displays the question
msg = input()
if (msg).lower() == answer:
#prints if the message is correct
print("Nice! " + msg + " is correct!")
#changes the correct variable
global correct
correct += 1
#checks to see if its false
else:
#prints out that the answer is false
print("Sorry, but " + msg + " is incorrect!")
#Below are the 4 different questions that this quiz will be issuing.
question("What function would you use to take input from the user?", "input")
question("What function outputs, or displays text?", "print")
question("What function checks whether a statement, or condition is true/false?", "if")
question("What is the keyword called when defining a function?", "def")
Percentage = correct/4
print("You got " +str(int(Percentage*100))+"%! Keep working hard!")