Python 3rd Quarter Flashcards
segment of code that performs a single task
Function
functions already made in Python
Built-in functions
functions made by the user
User defined functions
variable defined inside a function
Local variable
variable defined outside a function
Global variable
creates an anonymous function
Lambda
stores elements in last-in first-out fashion
Stack
what the header of a function consists of
Function name and parameter list
a loop within a loop
Nested loop
2 main types of functions
- Built-in function
- User defined function
where arguments to functions always appear in
Parentheses
returns the absolute value
abs( )
returns the length of an object
len( )
returns largest item in an iterable
max( )
returns smallest item in an iterable
min( )
returns a new sorted list from the items in alphanumeric order
sorted( )
returns the given sequence in reverse
reversed( )
rounds a decimal value to the nearest integer
round( )
sums the numeric values in an iterable
sum( )
short way of creating assignment statements when the variable is both at the left and right side
Shortcut operators
opens file object for reading or writing
open( )
common modes of interaction in opening files
r - reading plain text; default w - writing plain text a - appending plain text in existing file rb - reading binary data wb - writing binary data
closes opened file
close( )
reads all data from file into one text string
read( )