Building a Multiple Choice Quiz | Python | Tutorial 32

30
9



Giraffe Academy is rebranding! I’ve decided to re-focus the brand of this channel to highlight myself as a developer and teacher! The newly minted Mike Dane channel will have all the same content, with more to come in the future!

Source Code –

This video is one in a series of videos where we’ll be looking at programming in python. The course is designed for new programmers, and will introduce common programming topics using the python language.

Throughout the course we’ll be looking at various topics including variables, lists, tuples, loops, conditionals, object orientation, and much more.

If you’re enjoying Giraffe Academy and want to invest in our future, consider leaving a contribution

Links:
Website –
Facebook –
Twitter –

Nguồn: https://rozanighani.com/

Xem thêm bài viết khác: https://rozanighani.com/game/

30 COMMENTS

  1. Hi, Mike, your video is great, I want to randomize the questions along with answers and comments(if the answer selected is wrong, it will comment as 2 +2 =4 not 3 you choice. I got questions and answers correctly but the comments are not randomize with them correctly.

  2. This code didn't work for me. I copied the whole thing down and it said this:
    /usr/local/bin/python3.8 /Users/ryan/PycharmProjects/FreeTime/HowWellDoYouKnowMe.py
    Traceback (most recent call last):
    File "/Users/ryan/PycharmProjects/FreeTime/HowWellDoYouKnowMe.py", line 16, in <module>
    Question(questionPrompts[1], 'B'),
    IndexError: list index out of range

    Process finished with exit code 1

  3. Thanks you! So how do we use this as an desktop app? I want that users click onto this and play this quiz. How can I make that?

  4. what good is a quiz if no one can take it? how do you put it on the internet without the answers showing in the code?

  5. So I copied what he did exactly but when I run it it gives me an invalid syntax pointing to the 2nd question prompt I have and I can't figure out how to go past it

  6. Hi Mike! Wonderful explanation! 6:55 At 18th line why do we just use question_prompt instead of dot. And what is meaning behind this dot. Please reply am just a beginner. Thanks in advance.

  7. Hi. Your videos are a great help. I’m enjoying learning python. Do you have a video that shows how to export my quiz to a friend so they can play my quiz?

  8. To the people who cannot import Question, then why not just create a Question class on top of the code. I know that this isn't a great way of doing it but it works for me.

  9. wont ans = input(random.choice(question_prompts) just work? You just run if ans = a … elif ans = b … etc. etc.?

  10. this is wy too simple just one problem tht if we want to generate questions at random then we have to make significnt chnges in the way we defined things cz i tried many things with this structure only if anybody can plz cmnt

  11. This is perfect. Works great. Going to use this to analyse CSTA standards in my lessons. Hey, what software do you use to superimpose youself onto PyCharm screen? Thank you!!

  12. Hi Mike. Thanks for your teaching! Which code editor are you using? The same function did not run in Atom editor…

  13. I need to biuld a quiz that doesn't have right or wrong answers but rather different points acording to the answer that need to be summed at the end, How could I do that?

  14. I am currently trying to do a who wants to be a millionaire game. I of course have to validate what the user inputs. He gets to choose from choices A, B, C, or D, how would I be able to validate this? I normally use the while loop, but I don’t want to do something like this: while answer!= “a” or answer!=“A” or answer!=“b” or answer!=“B”…….. how would I be able to validate this? I am very new to programming, so excuse me hahahaha

  15. How could I make the questions come out randomly. I've imported the random modue, but I'm not sure if you could do this in the class file or the exam file?

  16. How would you turn the questions into an android app and make a game out of it? Is that possible through Python?

  17. Here is my dressed up version of a quiz game. However, I didn't use def statements. If you run this program from OS, you will even see how the OS characters can change colour, and stay separate. Each letter can be a different colour if you like. But you must run the program by double clicking the file you made from here and that's how you can see what the actual, dressed up output looks like. Copy it and run it. Save it as whatever you wish. Double click to run it and see the features you can create. You must import OS, just as you can see here. The last input statement just stops the OS Python file from closing and disappearing, so you can see what happens. Press Enter and the program will close and vanish, until you re open/run it again.

    import os

    tc=(

    'x1b[31m',

    'x1b[32m',

    'x1b[33m',

    'x1b[34m',

    'x1b[35m',

    'x1b[36m',

    'x1b[37m',

    )

    question_prompts1=(

    f'{tc[2]}How many sides does a Triangle have?nn{tc[1]}(a) {tc[2]}four

    sidesn{tc[1]}(b) {tc[2]}three sidesn{tc[1]}(c) {tc[2]}two sides',

    f'{tc[2]}How many sides does a Square have?nn{tc[1]}(a) {tc[2]}

    Two sidesn{tc[1]}(b) {tc[2]}Three sidesn{tc[1]}(c) {tc[2]}Four sides',

    f'{tc[2]}How many sides does a Pentagon have?nn{tc[1]}(a) {tc[2]}

    four sidesn{tc[1]}(b) {tc[2]}five sidesn{tc[1]}(c) {tc[2]}Three sides',

    f'{tc[2]}How many sides does a Hexagon have?nn{tc[1]}(a) {tc[2]}six

    sidesn{tc[1]}(b) {tc[2]}five sidesn{tc[1]}(c) {tc[2]}two sides',

    f'{tc[2]}How many sides does a Octagon have?nn{tc[1]}(a) {tc[2]}four

    sidesn{tc[1]}(b) {tc[2]}six sidesn{tc[1]}(c) {tc[2]}eight sides',

    f'{tc[2]}How many sides does a Dodecagon have?nn{tc[1]}(a) {tc[2]}eight

    sidesn{tc[1]}(b) {tc[2]}three sidesn{tc[1]}(c) {tc[2]}twelve sides',

    f'{tc[2]}How many sides does a Hexadecagon have?nn{tc[1]}(a) {tc[2]}sixteen

    sidesn{tc[1]}(b) {tc[2]}eight sidesn{tc[1]}(c) {tc[2]}six sides'

    )

    prompt=('b','c','b','a','c','c','a')

    score=0

    loop=0

    while loop<=6:

    os.system('cls')

    button=input((tc[1])+'nKnow Your Stuff!nn'+(tc[2])+'Know Your Polygonsnn'+

    question_prompts1[loop]+'nn'+(tc[0])+'READY:'+(tc[1])).strip()

    if button==(prompt[loop]):

    score+=1

    loop+=1

    os.system('cls')

    print(f'n{tc[2]}Know Your Polygonsnn{tc[2]}You got {score}/{len(question_prompts1)}

    questions correct.nCongratulations! Your total Prize Winnings: {tc[1]}${score*100*score:,}.00

    {tc[2]}Dollars.nn{tc[0]}READY:')

    input('nEND OF PROGRAM! Press Enter to quit.')

LEAVE A REPLY

Please enter your comment!
Please enter your name here