From the course: Programming Foundations: Real-World Examples
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Code reuse - Python Tutorial
From the course: Programming Foundations: Real-World Examples
Code reuse
- Eating nothing but omelets would get old real quick. Variety is the spice of life so I should probably add another function to my menu of breakfast recipes. - How about making some pancakes? - Sounds good to me. To make a pancake, I start by mixing together the ingredients in a bowl. Then I pour that mixture into a frying pan, I cook the pancake on one side, flip it, I cook the other side, and the output of that process, is a delicious pancake. Hmm, something seems familiar about this. Ah, the process for making a pancake has a lot in common with the process for making an omelet. Performing the same steps in multiple places is the perfect time to consider functionalizing that process. Back in idle I had the start a 102 breakfast function scripts open which has a new function for making pancakes. Inside of the make pancake function, I perform all of the steps in the pancake making process. I mix the ingredients, pour the mixture into a frying pan, cook the first side, flip it, and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.