This entry isn't a long one. I've been steady going along with the python udemy course and came across something very small, but so helpful. One of the recent projects I've worked on was a tip calculator. The program receives the input of the price, the options to tip 10, 12 or even 15 percent and then asks how may ways would you want to split the bill. I won't go into the details of it in this post, but there is a good bit of math that goes on with this program using integers and floats. While it seems these numbers should be able to be added, that isn't the case. Attempting to mathematically combine the two data types will result in an error.
So because of this, inputs that the user may put in have to be converted as the program runs to successfully get the output. I was able to successfully complete this project through the use of the type() function. A simple but helpful function, type() gives us the information of what the data type of that piece of information may be, allowing the programmer to be able to convert the information to a more useful data type that will allow for the program to run successfully.
Since learning about this function, I've been using is so much more along with the print() function. Being able to see the data type one may be working with helps so much. If you have some time, make use of it and see what you're able to learn.
Happy Coding.
Top comments (2)
Hey Jonathan,
Keep on truckin' ;)
Matt
Thanks for the encouragement Matt! I appreciate your kindness.