1/10
Vocabulary flashcards for review.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Built-in Function
Predefined functions provided by Python that perform specific tasks. Examples: input(), print(), len()
User-defined Function
Functions defined by the user using the 'def' keyword, requiring a function name, input(s), and output(s).
Lambda Function
Small, anonymous functions used for short, throwaway functionality, often passed directly to another function; defined using 'lambda arguments: expression'.
Module
A file containing Python code (usually functions or class definitions) that can be reused across scripts to organize code and avoid repetitions.
Custom Module
A .py file containing Python code (functions, constants, or classes) that can be imported into other Python scripts to reuse code and organize projects.
Function Handle
A way to reference a function, allowing it to be passed as an argument to other functions. Supported in MATLAB and can be generated in Python, though not as naturally.
print()
A built-in Python function that prints output to the console.
Anatomy of a built-in function
out1, out2, … = func_name(inp1, inp2, …)
Anatomy of a User-defined Function
def func_name(inp1, inp2, …) :
Function body
return out1, out2, …
Why would you use custom modules?
Custom modules allow for code organization, reuse, and separation of functionality, making programs easier to manage and maintain.
How do you create a custom module?
Write your Python functions and variables in a separate file with a .py extension. Then, you can import this file in your main program using the import statement.