Function arguments can be simple scalar values or complex structures. You may pass individual parameters or multiple parameters, and you may assign default values for optional parameters.
- [Instructor] Function arguments in Python…are fairly straightforward.…There are a few details that are worth noting.…So here in Komodo I've opened a working copy of function.py…from Chapter Seven of the Exercise Files,…and if I go ahead and run this,…you notice that down here at the bottom…we call main, and then main calls kitten,…and then kitten calls print with the literal string 'Meow.'…and that prints the string Meow.…Now if I want to pass an argument to kitten,…I can do that like this.…
I can put in a number five, and then down here in kitten,…in the parentheses, I can give it a variable name,…and then I can print that variable,…or I can do whatever I want with it,…and you notice that it prints.…I can pass multiple arguments, five, six, and seven,…by separating them with commas,…and likewise I can say a, b, and c,…and I can print them, a, b, and c,…and when we run this,…we get the five, six, and seven printed.…
If I don't pass enough arguments,…in other words if I pass a smaller number of arguments…in the function call than are expected…
- 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.