Python For Real Flashcards
parameter
a named variable that passes through a function’s argument(s)
module
a file that contains definitions—including variables and functions—that you can use once it is imported
generic import
Hint: It’s helpful to print the contents of a newly imported module you’re unfamiliar with to make sure you’re not reusing its content names.
simply calling a module in its entirety allowing access to all of its contents but forcing you to include the module name before each owned function (which may help by allowing you to write similarly named functions and variables)
import math
math.sqrt(#)
function import
calls a single function from a module freeing you from having to prefix each use of the function with the module name
from module import function
universal import
Hint: It’s common for professional developers to import only the functionality that is required, and not blindly import an entire module when there is no good reason to do so.
calling everything from a module and allowing you to call its contents without a module name prefix which can potentially cause the hazard of overlapping names if you write a similar function or variable yourself
from module import *
argument
the process(es) defined in a function such as multiplying the parameter(s) by 3 then returning the result
return
command to return values or to exit the method without returning a value
list
a datatype you can use to store a collection of different pieces of information as a sequence under a single variable name (the sequence starts at 0, not 1)
list_name = [item1, item2, item3, etc.]
index
address that identifies an individual item’s place on a list (starting with 0, not 1) allowing you access by including it’s identifier in brackets attached to and immediately following the list name
index_name[3]
slice
calls forth a section of a list or string beginning with the first included index item and ending with but not including the last index number written
index_name[3:9]
.index()
searches an index for the first instance of the parameters input and returns the numerical location
example.index(wanted)
.insert()
allows you to add an item to a list as well as its new specific index location if provided first in the parentheses subsequently shifting all other list items down the list in terms of index numbering (keep in mind that the number doesn’t have to be a digit, it can be the numerical content of another variable)
example.insert(#, new_item)
for loop
assigns to a variable (for variable) the value of a designated list (in list_name) whose contents will be used one at a time in the following code (:)
for variable in list_name:
code
.append()
adds a new variable to the end of your list
list_name.append(variable)
.sort()
alphabetizes the contents of your chosen list
list_name.sort()