Key Terms Flashcards
I/O
input output
Immutable
cannot change; strings are immutable ex. name = “Sam” , name[0] = ‘P’ returns TypeError
in-place algorithmn/function
(def., how to identify one)
- prodcues an output in the same memory that contains the data; transforms an input without using extra memory
- identification in python: usually will return None, but still modify the inputed data
Iterable
Object capable of returning its members one at a time
List Comprehension
- create a list based on another list
- create a list from a function
Example:
n_list = [x + 5 for x in [2,3,5] ]
snake_case v. CapWords
(when to use based on python style guide)
snake_case: used to define functions
CapWords: used to define classes
state diagram
Diagrams to give an abstract description of the behavior of systems.
String Interpolation
replacing a placeholder in a string with a designated corresponding value
When to use a dictionary ( 1 ); when to use a list ( 2 )?
- use dictionary when you want to store information, but do not need to know its exact index location and you do not need to sort.
- use list when you want to idex, slice, sort
Hash Table Definition
A data structure that holds data in key, value pairs.
(Dictionary in Python)
hash value
numeric value of a fixed length that uniquely identifies data
dictionaries in python must be hashable, meaning they cannot be a mulipart key
recursive functions
self referencing function
example:
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1)+fibonacci(n-2)
Garbage Collection
programming language manages memory automatically