Python Concepts From Module 2
Python Concepts From Module 2
Sections
User-defined functions
Built-in functions
Comments
User-defined functions
The following keywords are used when creating user-defined functions.
def
Placed before a function name to define a function
def greet_employee():
Defines the greet_employee() function
Built-in functions
The following built-in functions are commonly used in Python.
max()
Returns the largest numeric input passed into it
min()
Returns the smallest numeric input passed into it
sorted()
Sorts the components of a list (or other iterable)
import
Searches for a module or library in a system and adds it to the local Python
environment
import statistics
Imports the statistics module and all of its functions from the Python
Standard Library
Comments
The following syntax is used to create a comment. (A comment is a note programmers
make about the intention behind their code.)
#
Starts a line that contains a Python comment
"""
The estimate_attempts() function takes in a monthly
login attempt total and a number of months and
returns their product.
"""
Contains a multi-line comment that indicates the purpose of the
estimate_attempts() function