Final Project for AI_Wednesdays from Data Science Nigeria

Exercise: Write an article on Medium explaining your solution and problem solving process.

So here I am.

The question goes;

Now I took one look at this and thought “sure, I can do this, it’s easy”. This was because we’ve been dealing with exercises like this in class for weeks and I’m already quite familiar with them functions, arguments, parameters, variables and stuff. I decided to give it a try without using the ‘input’ method at first to at least see if I remember how to. Did it, it worked,

I was quite confident like yep, this shouldn’t take long (it later took me 2 days). I didn’t know about the ‘input’ function we were asked to incorporate so I went online to gather more info. Found out some stuff and tried to include it in my code. This was where it got tricky, this was where I got confused, this was where this simple exercise started looking like a complicated knot in my eyes. I mean I understood the concept of the ‘input’ function but why is it not just straightforward.

Here’s the process of all my trials and errors;

  1. I defined the input methods as a global variable, then built my ‘multiply’ function like this

2. This wasn’t the result i hoped for, it shouldn’t return an error as output, rather it should’ve just multiplied my values. After searching why this is so, I found out that an input method would always pass any argument (whether an integer or float) as a string, why this? why this headache?

3. Ran to Google again to search for how I could convert an input to a float or an integer, found something, tried it, still didn’t work. It was like my ‘else’ condition was invincible.

4. Now this is where I spent most of my time trying to figure out how to make my ‘else’ condition work. I needed to customize my function to return an “error: invalid argument” and my ‘else’ variable wasn’t working. I asked around I was told to read up on ‘try’ and ‘exceptions’. Did that and found out they are used to handle errors in Python codes. Perfect. Now how to use it, I watched several videos on YouTube, checked StackOverflow, Quora but none was giving me exactly what I wanted. So I just started trying it one way or the other following some examples I’ve seen hoping it’ll work. At a point I was tempted to send the whole question to someone who would help me just write the code and I would copy and paste because my head was aching, it wasn’t supposed to take that long (but then I’m a beginner, still have a lot to learn) to solve but I didn’t. After a few more tries, I eventually I cracked it. Hahahahaha.

Instead of ‘else’, I substituted with ‘except’.

No ‘else’ in sight but my function solves the problem that’s asked of it. It accepts both integer and float, it displays a customized error when a string is entered and it multiplies the values. So, yay me.

To end this, I would like to say thank you and well done to Ebenezer Don for being an awesome teacher. His classes are never boring and he manages to carry everyone along. Also, thank you Data Science Nigeria for providing this opportunity, it was a nice experience.

That’s all I guess. Thank you for reading.

Stay safe and drink enough water.

Peace :-)

--

--

--

Designer 💻 Writer 📝 Artist 🎨 Advocate for humanity, quality TV shows 🍿 & sleep 💤

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

3-way pivot table in Laravel

What happens when you type gcc main.c

Creating Custom Video Chat Application using WebRTC…

Push docker image to digital ocean image registry through Jenkins

Top 12 Computer Science Ph.D Fellowships

Scrape Malware Off of The Face of Your Enterprise

Moodle Installation Guide for Ubuntu Linux (2)

Exposing our applications with GCLB and Istio

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Zainab Balogun O.

Zainab Balogun O.

Designer 💻 Writer 📝 Artist 🎨 Advocate for humanity, quality TV shows 🍿 & sleep 💤

More from Medium

Happiness in Slavery

Reigning in Life

Lucky for you A narration of a few things I like.

Blockchain Technology — A Beginner’s Guide