Python Lesson 5 Reflections

Today, I learnt about a new coding concept called a function. Functions are very useful coding tools. They can easily perform logical tasks that need to be repeated. This code helps to repeat the logic over and over again so that it can be repeated an infinite number of times without having to type out the code over and over again. For example, you can simply give the function a name and use that name later on in the code in order to save time by not typing all the code out. This is a much easier process as a name is a lot easier to code out than the entire code again.

This is achieved by storing the logic/code into the memory itself, so it can be easily accessed again from the memory when the programmer calls on the shortened function later on in the program. Functions must begin with a letter and contain no spaces.

After familiarising ourselves with functions by trying out several examples on PyCharm, we started a new project. This project was called the ‘Chocolate Machine Challenge’. In this challenge, we have to use functions to determine how much change we need to give back when an amount of money is inputted by the user, and how we would have to use different functions in different scenarios where different bill types are used. During this class, I was only able to start off the easier part of the coding process which was to calculate the amount of change given since I had some difficulty writing out the code for different bill types. I will continue to try and do this next class.

Screen Shot 2016-11-03 at 5.48.41 PM

Leave a Reply