Cat COLABs With SPYDER

Raine Cat
4 min readSep 24, 2020

--

In this article, I’m going to share with you my personal experience and thoughts on utilizing both a notebook and a desktop IDE. Also, please excuse my little to none knowledge in python programming.

Being a fanatic that I am, I created a mini quiz about Greek Mythology using Google colab. The quiz basically comprises of multiple choice questions with the user entering the letter his answer.

Let me walk you through the codes that I made.

I used dictionary for its useful ‘key:value’ characteristics. What I did was to assign questions to each objects then put all these questions into a single dictionary with its corresponding answer key. You can directly input the questions to the dictionary but I opted to do otherwise to avoid some eye sore, if you know what I mean.

This variable is where the user’s score will be stored

This part of the program will be the introduction of the mini quiz. Just a simple print statement stating the mechanics of the game. It will also be where the user will input his username.

Now this is the heart of the program

This is the part that keeps the game moving. I used ‘for loop’ to call all the questions (which is the key) then I made the variable answer to store the player’s answer for each question.

I used ‘if statement’ to check the answer of the user and compare it with the correct answers(or what we call the value). Notice that I used the answer.lower() because as we all know, python is case sensitive.

Now for every correct answer, we will add 1 point to the score. This part is the score+=1. I also added some print statements to show the player if he got the answer correctly or not. In this case ‘Yass! Way to go!’ if he got the answer right and ‘Boo!’ if not.

Score calculation code

This part of the program shows how the score is being calculated and what the response would be if the score is perfect, passing score, and failing score.

The rate is calculated based on the total accumulated score. The usual formula for calculating the percentage was used.

Now we wanted to display the score, together with their ratings using the if, elif, and else statement. You can see the different statements used to indicate if the player got a perfect score, a passing score of less than 100 but greater than of equal to 70, and a failing grade.

If you are interested with how I encoded it, you can visit my github link.

For the program above, I used the Google Colab. Now what difference would there be with using an IDE such as Spyder? We’ll find out.

This is what our program would look like inside the Spyder. Apparently, the screen is divided into 3. We will see as we go along what these parts are for.

This is where we code our program and execute it.

This is the variable explorer. We can see here how the program runs step by step. We can also see the data type of each variable or objects, together with the size. The value shows the output of each line and also the ones being input by the player.

This is the console. This is where we can see what the program really looks like when being executed. All outputs and interactions with player and program are being made in this section.

As a beginner in programming, I highly prefer to use notebooks such as Jupyter and Google colaboratory because of its user-friendly interface. Most advantages we can enumerate in using a notebook would be for a beginner’s side. This also have automatic saving of codes, however it cannot be used offline.

As for using IDE like a spyder, I found each section of it useful. Also, the part where you are allowed to run a single line or execute a line and the other lines following it. We can get an immediate result for this. And we can easily check if we have error in that line without having to run the entire program.

I guess that sums up how a Cat (no, I’m not a cat person) codes using both COLAB (notebook) and SPYDER (IDE).

--

--

Raine Cat
Raine Cat

Written by Raine Cat

Licensed Electronics Engineer | Aspiring Data Scientist | a little bit stuck in the MiddlE | the name is an oxymoron

No responses yet