How #CertifiedFilipino are you? version 2.0
The remake of the quiz “How #CertifiedFilipino are you?” with more advanced python coding.
At least for me, the code seems more advanced.
Without further ado, here’s the link of the upgraded quiz in my Github repo:
Now, let’s discuss one-by-one what changes I did to make it happen.
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.)
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.
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.
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.
And voila, here’s what the quiz will look like.
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!