Hello, my name is Manuel and I run ManyProgramming™. Today we will be making a functional Multiple-Choice program. I will be making a quiz with five Multiple-Choice questions. At the end it will show me my score.
Today I will be showing you pretty complex and diverse multiple-choice quiz that has a lot of different features. I will try to split the quiz up into small diverse parts which we can then put completely together at the end. I will also put up a copy of the completed quiz! WARNING! WHEN I USE THE ‘#’ THAT MEANS THAT PYTHON ONLY TAKES IT IN AS TEXT AND DOESN’T PROCESS IT!
Firstly, we’ll start off with the beginning part.
print ('WELCOME TO THE MULTIPLE CHOICE TEST\n') name = input('WHAT IS YOUR NAME? ') print ('\nHI THERE ' + name + '! LET''S PLAY A GAME!\n') print ('\n-----------------------------------------------------------\n') score = 0
First it will say ‘WELCOME TO THE MULTIPLE CHOICE TEST’, then, it will ask you for your name. Then after you put your name in it will say ‘HI THERE What_ever_your_name_is! LET’S PLAY A GAME! It will then have a line that splits the welcoming & the actual questions.
Secondly, we will do the questions.
print ('QUESTION 1: WHAT IS THE LARGEST OCEAN IN THE WORLD?\n') print ('A. The Indian Ocean') print ('B. The Pacific Ocean') print ('C. The Atlantic Ocean') print ('') Q1answer = "B" Q1response= input('Your answer : ') if (Q1response != Q1answer): print ('Sorry, that is incorrect! The answer was B') else: print ('Well done! ' + Q1response + ' is correct!') score = score + 1 print ('Your current score is ' + str(score) + ' out of 5') print ('\n-----------------------------------------------------------\n')
Now this is the question. The question will have three options as answers. You have to type the letter that you think is the correct answer; if you get the answer right, then it will say ‘Well done! Whatever_letter_you_said_correctly is correct!’but, if you get it wrong, then it will say that it is incorrect and will tell you the right answer. If you want to have multiple questions, then you just copy everything I wrote above multiple times and just edit the questions and answers. At the end the score will be +1 every time you get the answer correct! And, at the very end, it will tell you your current score and then put a line, separating the different questions!
Lastly, the part at the end is probably the easiest to understand. What you see below tells Python that it needs to print the score you got, in my case out of five because I have 5 questions, but you can decide out of how much your score should be. At the bottom, it has a line which says that the quiz is ended (Not to Python because it doesn’t take that in but to you).
print ('Your total score is ' + str(score) + ' out of 5') print ('\n-----------------------------------------------------------\n') # Thank you for taking part in my Quiz!!
Now if you put all this together, then you will have a very long program and as a programmer, you want to save as much space as you can so I will now show you how to shorten everything. It will be the same, basic principal as the program we did last blog; as you’ll see below.
def question1(Quest, Ans1, Ans2, Ans3, Ans): global score correct_answer=False for counter in range (3): x=input(Quest) if x.upper()==Ans.upper(): print('Well Done, You got it Correct, +1 Point') score+=1 correct_answer=True break else: print('Sorry, You got it Incorrect, Better luck Next Time! ') if not correct_answer: print('The Answer was',Ans) print('ManyProgramming_Quizquam','\nPlease type in the letter of your selected choice!') score=0 question1('What is the largest Animal on Earth?','\nA= Blue Whale','\nB= Elephant','\nC= Humpback Whale,' A') question1('What is the fastest car on Earth?','\nA= Muscle Cars','\nB= Ferrari','\nC= Koenigsegg',' C') question1('What is the most Deadly Spider on Earth?','\nA= Tarantula','\nB= Black Widow Spider','\nC= Daddy Long Legs',' B') print('\n-----------------------------------------------------------------) print('\nCongratulations, Your Total Score was', score)
This way you can add as many questions as you would like by simply adding a line that tells the information of the question, as I have done above. The idea is very simple; it uses a function which determines whether the answer is right of wrong. I also have written all the different objects and used ‘\n’ to tell Python that the three options for the multiple-choice test will be on separate lines. It is also the same principal as the first program I made; if you didn’t read it then Click Here to Open the Blog!!
Thank you for reading my blog. I hope you have a wonderful day. If you want to have the quiz, email programmingmany@gmail.com and I will send you the quiz and how to load it. Also, get ready for my Christmas blog. I will post at 7:00pm on Monday the 24th of December! If you would like to see my book reviews blog then Click Here!

