How #CertifiedFilipino Are You?

Jela Nalica
The Startup
Published in
5 min readSep 20, 2020

A Python quiz to check if you’re a true Filipino.

Photo by GoodEats YQR on Unsplash

I’ll be honest with you. I’m 100% Filipino (and I’m so proud of that) but I failed this quiz. But it’s not what you think.

I failed to code the quiz properly before anyone could even answer it. Simply because my code did not work as it was supposed to be.

It was frustrating. Then I got more frustrated seeing the codes of my co-scholars who presented, and I was just amazed how elegant their code is, and how they get to code like that after just 8-hours of Python lecture class. Well, I know some of them already have the advantage because they’ve already been using the language for work, and some took a prior course before class.

And to keep things short, today’s class just slap me in the face and said “Keep up Jela!”. Well, challenge accepted!

I first wrote my code in Colab and define functions without fully understanding how functions are supposed to work. So time is almost up but I’m still rerunning my code, trying to figure out why I got it wrong. And during the last minute, I rewrite my code and take out all the functions. Finally, it worked! See the link below to check it out.

Certified Filipino Quiz #1

As you can see, it is an abuse of the text code feature in Colab. I just realized that after seeing the works of my co-scholars (Thank you FTW-DS4 sisters for making me realize that!)

But I assure you it’s working. You just have to run the code yourself.

After class, I continue coding and did not stop until I get the proper one. Hence, this is my Certified Filipino Quiz #2.

Certified Filipino Quiz #2

This code is more user-friendly as what my caption states (promised!). In this code, I only use one text cell and one code cell to write the codes for my quiz. The major improvement was writing my questions in one list (and not using text cells. Yey!). Then a “for loop” to check the answers, and used “if-else” to evaluate the score. I also tried making a function “intro” though it is unnecessary.

However, I saw one problem — What if the quiz taker will keep answering in the wrong format?

Thus, I made a Certified Filipino Quiz #3. This version will keep pushing you to try again and answer properly before moving on to the next question.

Certified Filipino Quiz #3

The differences it has with my version #2 have improved the code’s readability by adding comments, take out the unnecessary function “intro”, and most importantly the additional “while loop”. With the added “while loop”, the user should only type a “yes” or “no”. And this code will not quit until you answer properly.

And there you have it! I’ve successfully made a Python Quiz.

Next, what will happen if I rewrite my code in the Spyder IDE?

A Python in Spyder — Impossible!

That’s supposed to be a joke but never mind.

To rewrite my code from Colab to Spyder, I just did a simple copy-and-paste.

Certified Filipino Quiz #3 in Spyder

Then, I run the code.

Run — Certified Filipino Quiz #3 in Spyder

Tada! My code from Colab still works here in Spyder but if you look closely, a lot of warning signs appeared in the editor pane. It’s because I enabled the code style linting to conform to PEP 8 convention. If you want to enable yours as well, just go to “Preferences” then under the “Completion and Linting” option, go to ”Code Style” tab and click the “Enable Code Style Linting”

PEP 8 Convention — Enabled

For me, this is one of the main features here in Spyder that you can’t have in Colab. It strictly checks if your indents, code line length, etc. follow the PEP 8 convention to improve the readability of your code. It’s perfect too if you’re an OC like me.

Unlike in Colab, which only has one window where you can both code and run your code, Spyder’s default workspace have three — editor, console, and variable explorer.

Spyder’s default workspace window

Generally, Spyder and Colab are both IDE for Python but both designed for a different purpose. Colab, from the name itself, is done online and used by people who would love to collaborate and work together in coding. Colab is also favorable for Data Science because it has more packages that can do visualization tools than Spyder. While Spyder is designed for development such as apps, websites, etc.

And that’s all for now. I hope you’d get a thing or two from my coding experience. Also, please try to answer my #CertifiedFilipino Quiz cause I would really love to hear your comments and help me improve my skills.

print(“Thank you very much!”)

Photo by Jon Tyson on Unsplash

--

--