idk random
Key Terms
Don't Repeat Yourself (DRY) is a principle of software engineering aimed at making it easier to maintain, update, and debug code.
Functions are named containers for statements that can be invoked to execute code, improving readability and reducing repetition.
Built-in functions like print(), len(), and type() come with Python, so they can be called without being defined first.
A docstring is a string written on the first line of a function's body that describes what the function does. VS Code and the built-in help() function show it to whoever is about to call the function.
Parameters are placeholders for inputs given to the function. Parameters can be used by their function to change the function's behavior.
Arguments are the actual values given when invoking a function.
Return statements allow functions to produce values that can be used elsewhere in your program and terminate function execution. A function with no return statement returns None.
Parameters can have default values, and arguments can be passed by keyword as well as by position.
A NameError is raised when a line uses a name that does not exist at the moment that line runs: the name is misspelled, it belongs to a different function's scope, or it is assigned (or its function is defined) further down the file than the line that uses it.
A TypeError is raised when a value is the wrong type for what the code asks of it, such as adding a string to a number, or when a function is called with the wrong number of arguments.
Scope determines where variables can be accessed.
Global scope is the file, outside of any function. A variable assigned there is reachable anywhere in that file.
Local scope is the inside of a function. A variable or parameter assigned there exists only while that function is running and is reachable only within it.