How #CertifiedFilipino are you? version 2.0

Jela Nalica
3 min readOct 2, 2020

The remake of the quiz “How #CertifiedFilipino are you?” with more advanced python coding.

At least for me, the code seems more advanced.

Photo by Jack Sloop on Unsplash

Without further ado, here’s the link of the upgraded quiz in my Github repo:

ADV_CertifiedPinoyQuiz_Rev_4(FINAL).ipynb

Are you a #CertifiedFilipino? 2.0

Now, let’s discuss one-by-one what changes I did to make it happen.

Creating a text file in Python.

I started my code by creating a text file “pinoyquiz.txt” then writing my questions in it. Then in the next code, I open (or read) the file I created. The main difference in creating a file for my quiz questions is that I can edit my questions in the text file, instead of editing the questions directly in the code.

(You can access the text file you created in python if you open the Files icon.)

Opening “pinoyquiz.txt”

Next, I created two empty lists: “player” list will hold the name and score of each quiz taker then it will be appended in the “players” list to store all quiz takers.

Then I created two functions:

check_ans() function to record how many “yes” answers a player will have.

Sort(players) function sort the scores of the players from highest to lowest.

When I defined these functions, I also learned the use of “global” keyword through edube.org which offers free python tutorials that are very beginner-friendly.

Defining your own functions.

After defining the necessary functions, I incorporate them into the code of answering the quiz. It’s not much different from my first quiz version except it will limit accepting answers to ten quiz takers only.

Quiz Proper

Finally, I added a “Player Tracker” where it can keep all the names and scores of the quiz takers which will be sorted and printed after finishing the quiz so the taker can see his or her rank.

Player Tracker Code

And voila, here’s what the quiz will look like.

My Quiz Output

Go answer it too and let’s see who’s more Filipino among us.

P.S.

All questions where inspired by both my experience and memes I saw on Facebook. Have fun!

--

--