I Created A Quiz Using Python

Kelsey Lopez

--

I created a Trivia Quiz using Python! You can access it here to find out if you can have a perfect score or if you just want to check out my code.

Quick overview:

Once you run the code, this is what you will see:

This will let you input your name. Once you do, you will be asked to choose if you want to start or to quit. Once you choose to start, the first question will appear. You will get two points for every correct answer you get.

Five questions randomly appear from a list I created and once you have answered all of them, your score will appear along with the last nine players that played before you.

Three parts of my code that just make sense:

  1. import random

This allows your code to choose questions randomly from your list. Right now, I only have a few trivia questions placed on my list. But if you have lots of questions prepared, you don’t want your players seeing the same 5 questions do you?

2. name_of_list.pop(index)

If your program randomly chooses questions, one thing you don’t want to happen is for your program to choose the same question over and over. This is the answer to that. It removes the chosen question along with the choices corresponding to it.

3. df.to_csv()

This saves the player’s name and score to a csv file so other players know that you have played as well. The ‘tail(10)’ in the print command at the bottom of the screenshot allows you to only display the last 10 players along with their scores.

Wanna try and play or check the rest of my code? Go ahead and check it here.

--

--

No responses yet