Python Tutorial v3.2.5 Lesson 12.1 - User Defined Functions and the Return Statement

preview_player
Показать описание
2:37 Click to skip the Introduction to Lesson 12.1.
9:03 Explanation of the return statement vs. the print() function.

Lesson 12.1 introduces user defined functions. 'def' and 'return' are both introduced and explained, as well as the difference between a parameter and an argument. An explanation is given of how a return statement works and how it is different from a print() function, which is a common hurdle for many beginning programmers.

This is an introductory series of Python tutorials. This course, from start to finish, is designed to help someone who has never programmed before learn the basics of coding in Python. As this series continues, we examine more advanced Python techniques, functions, and methods.

Keep in mind this tutorial is using an older version of Python, v3.2.5. You will need to click on the "View Older Releases" button to use this specific version. Using the newer versions will not be an issue at this point, but when the lesson proceeds to basic graphics, the Pygame Module we'll use does not support v3.3+ at this time.
Рекомендации по теме
Комментарии
Автор

Thanks for clarifying the difference between return and print command. Print does not retain a value of a function, whereas return retains the value of the function... But still has to have deeper understanding, like when it is written "Return True (or False)" in the function...

SheikhAhmadShah
Автор

Does anyone know why if i print this code in the file, it doesn't work? I'm trying to figure out how to start the challenge a couple videos ahead and I'm totally lost on how to start:

def x(num):
return num ** 2
x(4)

it does nothing in the shell??? but if i put x(4) in the shell, it works??

timmellis