any() on a list?any() function will randomly return any item from the list.any() function returns True if any item in the list evaluates to True. Otherwise, it returns False.any() function takes as arguments the list to check inside, and the item to check for. If "any" of the items in the list match the item to check for, the function returns True.any() function returns a Boolean value that answers the question "Are there any items in this list?"linked listqueuesetOrderedDictStatic methods are called static because they always return "None".Static methods can be bound to either a class or an instance of a class.They serve mostly as utility methods or helper methods, since they can't access or modify a class's state.Static methods can access and modify the state of a class or an instance of a class.if/else statement, used when testing for equality between objects.count, fruit, price = (2, 'apple', 3.5)
tuple assignmenttuple unpackingtuple matchingtuple duplication".delete()" methodpop(my_list)del(my_list)".pop()" methodto capture command-line arguments given at a file's runtimeto connect varios systems, such as connecting a web front end, an API service, a database, and a mobile appto take a snapshot of all the packages and libraries in your virtual environmentto scan the health of your Python ecosystem while inside a virtual environment"O(n)", also called linear time"O(log n)", also called logarithmic time"O(n^2)", also called quadratic time"O(1)", also called constant timeclass Game: passdef Game(): passdef Game: passclass Game(): pass-def sum(a, b):
    """
    sum(4, 3)
    7
    sum(-4, 5)
    1
    """
    return a + b
-def sum(a, b):
    """
    >>> sum(4, 3)
    7
    >>> sum(-4, 5)
    1
    """
    return a + b
-def sum(a, b):
    """
    # >>> sum(4, 3)
    # 7
    # >>> sum(-4, 5)
    # 1
    """
    return a + b
-def sum(a, b):
    ###
    >>> sum(4, 3)
    7
    >>> sum(-4, 5)
    1
    ###
    return a + b
setlistNone. You can only build a stack from scratch.dictionarycollege_years = ['Freshman', 'Sophomore', 'Junior', 'Senior']
return list(enumerate(college_years, 2019)
[('Freshman', 2019), ('Sophomore', 2020), ('Junior', 2021), ('Senior', 2022)][(2019, 2020, 2021, 2022), ('Freshman', 'Sophomore', 'Junior', 'Senior')][('Freshman', 'Sophomore', 'Junior', 'Senior'), (2019, 2020, 2021, 2022)][(2019, 'Freshman'), (2020, 'Sophomore'), (2021, 'Junior'), (2022, 'Senior')]defaultdict work?defaultdict will automatically create a dictionary for you that has keys which are the integers 0-10.defaultdict forces a dictionary to only accept keys that are of the types specified when you created the defaultdict (such as string or integers).defaultdict will create a new key for you instead of throwing a KeyError.defaultdict stores a copy of a dictionary in memory that you can default to if the original gets unintentionally modified.class Game.LogicGame(): passdef Game(LogicGame): passclass Game(LogicGame): passdef Game.LogicGame(): passself means that no other arguments are required to be passed into the methodThere is no real purpose for the self method; it"s just historic computer science jargona that Python keeps to stay consistent with other programming languagesself refers to the instance whose method was calledself refers to the class that was inherited from to create the object using selfYou can assign a name to each of the namedtuple members and refer to them that way, similarly to how you would access keys in dictionaryEach member of a namedtuple object can be indexed to directly, just like in a regular tuplenamedtuples are just as memory efficient as regular tuplesNo import is needed to use namedtuples because they are available in the standard libraryInstance methods can modify the state of an instance or the state of its parent classInstance methods hold data related to the instanceAn instance method is any class method that doesn"t take any argumentsAn instance method is a regular function that belongs to a class, but it must return None-num_people = 5
if num_people > 10;
    print("There is a lot of people in the pool.")
elif num_people > 4;
    print("There are some people in the pool.")
elif num_people > 0;
    print("There are a few people in the pool.")
else:
    print("There is no one in the pool.")
-num_people = 5
if num_people > 10;
    print("There is a lot of people in the pool.")
if num_people > 4;
    print("There are some people in the pool.")
if num_people > 0;
    print("There are a few people in the pool.")
else:
    print("There is no one in the pool.")
-num_people = 5
if num_people > 10:
    print("There is a lot of people in the pool.")
elif num_people > 4:
    print("There are some people in the pool.")
elif num_people > 0:
    print("There are a few people in the pool.")
else:
    print("There is no one in the pool.")
-if num_people > 10;
    print("There is a lot of people in the pool.")
if num_people > 4;
    print("There are some people in the pool.")
if num_people > 0;
    print("There are a few people in the pool.")
else:
    print("There is no one in the pool.")
It protects the data from outside interferenceA parent class is encapuslated and no data from the parent class passes on to the child classIt keeps data and the methods that can manipulate that data in one placeIt only allows the data to be changed by methodsAn if/else statement tells the computer which chunk of code to run if the instructions you coded are incorrectAn if/else statement runs one chunk of code if all the imports were succesful, and another chunk of code if the imports were not succesfulAn if/else statement executes one chunk of code if a condition it true, but a different chunk of code if the condition is falseAn if/else statement tells the computer which chunk of code to run if the is enough memory to handle it. and which chunk of code to run if there is not enough memory to handle itdictionarysetNone. You can only build a stack from scratch.listmy_game = class.Game()my_game = class(Game)my_game = Game()my_game = Game.create()The function will return a RuntimeError if you don't return a value.If the return keyword is absent, the function will return None.If the return keyword is absent, the function will return True.The function will enter an infinite loop because it won't know when to stop executing its code.pass statement in Python?yield statement of a generator and return a value of None.while or for loop and return to the start of the loop.argumentsparadigmsattributesdecoratorsslotdictionaryqueuesorted listwhen it encounters an infinite loopwhen it encounters an if/else statement that contains a break keywordwhen it has assessed each item in the iterable it is working on or a break keyword is encounteredwhen the runtime for the loop exceeds O(n^2)fruits = ['Apples', 'Oranges', 'Bananas']
quantities = [5, 3, 4]
prices = [1.50, 2.25, 0.89]
# Desired output
[('Apples', 5, 1.50),
('Oranges', 3, 2.25),
('Bananas', 4, 0.89)]
-output = []
fruit_tuple_0 = (first[0], quantities[0], price[0])
output.append(fruit_tuple)
fruit_tuple_1 = (first[1], quantities[1], price[1])
output.append(fruit_tuple)
fruit_tuple_2 = (first[2], quantities[2], price[2])
output.append(fruit_tuple)
return output
-i = 0
output = []
for fruit in fruits:
    temp_qty = quantities[i]
    temp_price = prices[i]
    output.append((fruit, temp_qty, temp_price))
    i += 1
return output
-groceries = zip(fruits, quantities, prices)
return groceries
>>> [
('Apples', 5, 1.50),
('Oranges', 3, 2.25),
('Bananas', 4, 0.89)
]
-i = 0
output = []
for fruit in fruits:
    for qty in quantities:
        for price in prices:
            output.append((fruit, qty, price))
    i += 1
return output
The all() function returns a Boolean value that answers the question "Are all the items in this list the same?"The all() function returns True if all the items in the list can be converted to strings. Otherwise, it returns False.The all() function will return all the values in the list.The all() function returns True if all items in the list evaluate to True. Otherwise, it returns False.->>> dice = Game()
>>> dice.roll()
->>> dice = Game(self)
>>> dice.roll(self)
->>> dice = Game()
>>> dice.roll(self)
->>> dice = Game(self)
>>> dice.roll()
backtrackingdynamic programmingdecrease and conquerdivide and conquerO(1), also called constant timeO(log n), also called logarithmic timeO(n^2), also called quardratic timeO(n), also called linear timeAbstraction means that a different style of code can be used, since many details are already known to the program behind the scenes.Abstraction means the implementation is hidden from the user, and only the relevant data or information is shown.Abstraction means that the data and the functionality of a class are combined into one entity.Abstraction means that a class can inherit from more than one parent class.def print_alpha_nums(abc_list, num_list):
    for char in abc_list:
        for num in num_list:
            print(char, num)
    return
print_alpha_nums(['a', 'b', 'c'], [1, 2, 3])
-a 1
a 2
a 3
b 1
b 2
b 3
c 1
c 2
c 3
-['a', 'b', 'c'], [1, 2, 3]
-aaa
bbb
ccc
111
222
333
-a 1 2 3
b 1 2 3
c 1 2 3
Game?-my_game = Game()
my_game.roll_dice()
-my_game = Game()
self.my_game.roll_dice()
-my_game = Game(self)
self.my_game.roll_dice()
-my_game = Game(self)
my_game.roll_dice(self)
-def sum(a, b):
    # a = 1
    # b = 2
    # sum(a, b) = 3
    return a + b
-def sum(a, b):
    """
    a = 1
    b = 2
    sum(a, b) = 3
    """
    return a + b
-def sum(a, b):
    """
    >>> a = 1
    >>> b = 2
    >>> sum(a, b)
    3
    """
    return a + b
-def sum(a, b):
    '''
    a = 1
    b = 2
    sum(a, b) = 3
    '''
    return a + b
When instantiating an object, the object doesn't inherit any of the parent class's methods.When instantiating an object, the object will inherit the methods of whichever parent class has more methods.When instantiating an object, the programmer must specify which parent class to inherit methods from.An instance of the Game class will inherit whatever methods the BoardGame and LogicGame classes have.a generic object class with iterable parameter fieldsa generic object class with non-iterable named fieldsa tuple subclass with non-iterable parameter fieldsa tuple subclass with iterable named fields&&===||fruit_info = {
'fruit': 'apple',
'count': 2,
'price': 3.5
}
fruit_info ['price'] = 1.5my_list [3.5] = 1.51.5 = fruit_info ['price]my_list['price'] == 1.55!=6
yesFalseTrueNoneThe __init_method makes classes aware of each other if more than one class is defined in a single code file.The _init_method is included to preserve backwards compatibility from Python 3 to Python 2, but no longer needs to be used in Python 3.The __init__() method is a constructor method that is called automatically whenever a new object is created from a class. It sets the initial state of a new object.The __init__ method initializes any imports you may have included at the top of your file.How many microprocessors it would take to run your code in less than one secondHow many lines of code are in your code fileThe amount of space taken up in memory as a function of the input sizeHow many copies of the code file could fit in 1 GB of memoryfruit_info = {'fruit': 'apple', 'count': 2, 'price': 3.5}fruit_info =('fruit': 'apple', 'count': 2,'price': 3.5 ).dict()fruit_info = ['fruit': 'apple', 'count': 2,'price': 3.5 ].dict()fruit_info = to_dict('fruit': 'apple', 'count': 2, 'price': 3.5)fruits = {'Apples': 5, 'Oranges': 3, 'Bananas': 4}
fruit_names = [x in fruits.keys() for x]fruit_names = for x in fruits.keys() *fruit_names = [x for x in fruits.keys()]fruit_names = x for x in fruits.keys()backtrackingdivide and conquerdynamic programmingdecrease and conquerself keyword when defining or calling methods on an instance of an object?self refers to the class that was inherited from to create the object using self.self method. It's just legacy computer science jargon that Python keeps to stay consistent with other programming languages.self means that no other arguments are required to be passed into the method.self refers to the instance whose method was called.A class method is a regular function that belongs to a class, but it must return None.Class methods can modify the state of the class, but they can't directly modify the state of an instance that inherits from that class.A class method is similar to a regular function, but a class method doesn't take any arguments.Class methods hold all of the data for a particular class.def getMaxNum(list_of_nums): # body of function goes herefunc get_max_num(list_of_nums): # body of function goes herefunc getMaxNum(list_of_nums): # body of function goes heredef get_max_num(list_of_nums): # body of function goes here explanationmaxValue = 255max_value = 255MAX_VALUE = 255MaxValue = 255myset = {0, 'apple', 3.5}myset = to_set(0, 'apple', 3.5)myset = (0, 'apple', 3.5).to_set()myset = (0, 'apple', 3.5).set()__init__() method that takes no parameters?-class __init__(self):
    pass
-def __init__():
    pass
-class __init__():
    pass
-def __init__(self):
    pass
NoneFor any given Node in a binary Search Tree, the child node to the left is less than the value of the given node and the child node to its right is greater than the given node. (Not Sure)Binary Search Tree cannot be used to organize and search through numeric data, given the complication that arise with very deep treesThe top node of the binary search tree would be an arbitray number. All the nodes to the left of the top node need to be less than the top node's number, but they don't need to ordered in any particular wayThe smallest numeric value would go in the top most node. The next highest number would go in its left child node, the the next highest number after that would go in its right child node. This pattern would continue until all numeric values were in their own nodeA decorator is similar to a class and should be used if you are doing functional programming instead of object oriented programming.A decoratore is a visual indicator to someone reading your code that a portion of your code is critical and should not be changedYou use the decorator to alter the functionality of a function without the without having to modify the functions codeAn import statement is preceded by a decorator, pyhton knows to import the most recent version of whatever package or library is being importedOnly in some situations, as loops are used ony for certaing type of programmingWhen you need to check every element in an iterable of known lengthWhen you want to minimize the use of strings in your codeWhen you want to run code in one file for a function in another filedef tax(my_float): '''Calculates the sales tax of a purchase. Takes in a float representing the subtotal ...???
def tx(amt): '''Gets the tax on an amount.'''def sales_tax(amount): '''Calculates the sales tax of a purchase. Takes in a float representing the subtotal ...???def calculate_sales_tax(subtotal): pass