30 Days of Code — Day 2

Tyler Carter
2 min readMar 8, 2021
Photo by Chris Ried on Unsplash

As a forcing function to get myself into the habit of writing these articles — I have decided to write an article for each day of the 30 Days of Code challenge from Hacker Rank.

The Task

Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal’s total cost. Round the result to the nearest integer.

The Code

As a note, the libraries are automatically included as part of the solution checker. While they are usually not used, this is the companies way of restricting what libraries you can use to solve the tasks.

The Result

>? 12.00
>? 20
>? 8
… 15

Conclusion

I had to actually look into the global variables and they functioned in this instance. I have a lot of experience building function definitions but I have not really done much with global variables. After a bit of research I have been able to conclude that there is a time and a place to use them but they should be used sparingly.

Here is a link to the day_1 answer/challenge I wrote about previously: 30 Days of Code — Day 1

--

--

Tyler Carter
0 Followers

I am currently an Operations Program Manager for Microsoft. I have been teaching myself Python to use for Data Analytics and Machine Learning.