From the course: Python for Students (2019)

Unlock this course with a free trial

Join today to access over 22,700 courses taught by industry experts.

Putting it all together

Putting it all together - Python Tutorial

From the course: Python for Students (2019)

Putting it all together

- [Voiceover] Using variables and functions together is really where programs start to come to life. When you call a function, it doesn't only have to print information, it can also process and return data, which we can then store in a variable. The value of function returns is called a "return value". Let's get started with an example. In this example, we have a function called pizza_name, which takes the name of a topping, and prints out the name of the pizza. Let's go ahead and run it to see what it outputs. You can see that I called the function with the word "cheese", and it outputs the phrase "cheese pizza". Instead of the function just printing this string, let's have it return the string so that we can store it in a variable. To do that, I'm going to remove the print function, and instead use the keyword "return". I can now store that string into a variable called "pizza". We can now print the variable "pizza" in…

Contents