All functions return a value. If a no value is specified, a function returns the special "None" value. A function may return a scalar or a container or any object.
- [Bill] In Python, there is no distinction…between a function and a procedure.…All functions return a value.…Here in Komodo,…I've opened a working copy of function.py…from chapter seven of the exercise files,…and I'm going to come down here and I'm going to assign…the return value from kitten to a variable,…and then I'm going to print that, along with its type.…And so when I save and run this,…you notice that the type is the none type,…and the value is none.…
And that's because if there's no return statement,…or an empty return statement, a function returns none.…If I give it a return statement, and say return a number,…then we save and run,…and now the type is Int and the number is returned.…Likewise I can return a list,…and save and run,…and I get a list, or I can return a dictionary,…and when I save and run, we get that dictionary.…
So because of Python's effective object model,…Python functions are capable…of returning simple or complex values.…We'll see many examples of this…as we go through this course.…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficiently (2017)with Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.