The road to learning Python comes along with several roadblocks, challenges and obstacles to overcome. As I continue to learn how the code operates, I see the value of thinking through the lesson I am currently taking with Coursera on becoming an IT Professional with Google.
As many know, Google does not make it easy to learn the basic fundamentals of Python with this course. I personally have seen vague questions and assessments derail novice programmers. To a degree, I understand weeding out the weak, but I do disagree with the lack of consistency in their learning methods.
For example, in the second week of the course I am taking, I am given a problem to solve regarding defining a function.
Do you think you can flesh out your own function? I think you can! Let’s give it a go.
Flesh out the body of the print_seconds function so that it prints the total amount of seconds given the hours, minutes, and seconds function parameters. Remember that there are 3600 seconds in an hour and 60 seconds in a minute.
def print_seconds(hours, minutes, seconds):
print(___)
print_seconds(1,2,3)
The lesson provides instruction on how to define block of text but not integers. The goal is to define hours, but without prior instruction to show how to properly perform the task, like many questions from Google, leaves the learner frustrated.
My theory is to follow what little instruction they provide and used the following code:
def print_seconds(hours, minutes, seconds):
print(3600, 60, 1)
print_seconds(hours)
Google’s response is that I have not defined hours yet, but I did follow their syntax regarding their previous example using text compared to numbers. I also attempted to put quotes around the numbers in the second line of code, to exactly follow the example the learning material provided to the learner.
On one hand, I am extremely frustrated that I have been working at this one problem for over an hour to properly learn the correct method in defining a function. The course lacks multiple examples to use in regards to the question they ask. It creates a major roadblock, but I will say that writing this article is pushing me to not give up, and continue working on the problem until I find the solution.
In addition, Coursera is cleaver about hiding the previous example from the learner in order for them to remember it for the practice question. Since I am just trying to understand the principals of defining a function, I am thrilled to share the idea of taking notes on key examples on a secondary screen or notepad to use as a reference. Properly taking notes is part of finding the solution to this complex problem.
After close to being stuck on the same problem for close to two hours, I decided to take the text from the course and search for it in Google. I find it assuming that a course created by Google did not have sufficient information to complete the course, and I had to result to “Googling” the Web for more information. I am not sure if this is “giving up” or not. Since I am continuing with the course, I find this to be “additional research.”
That being said, a Reddit user also experienced the same roadblock I witnessed, they took the time to create a post in Reddit asking for help.
The correct way of solving the problem was to use the following formula:
def print_seconds(hours, minutes, seconds):
total_seconds=hours*3600+minutes*60+seconds
print(total_seconds)
print(1,2,3)
Here is your output:
3723
It appears the took the number 1 and replace it with 3600, they took the 2 and multiplied the minutes to equal 120, and used the 3 to correlate to seconds. They added these numbers up to reach 3723. The feedback provided was unhelpful when trying to reach this solution.
The overall lesson for today is when you hit a roadblock, research online to see if another person has hit a similar roadblock, and then look into how they arrived to the solution. My theory is that it matters less how a person finds a solution, but more importantly that they find the best solution for the problem.