ANSWERS(RATED A+)
Branching - ANSWERdirects a program to execute either one group of statements or
another
Function - ANSWERPredefined set of code that takes in Input and produces some
sort of Output
Function Cell - ANSWERfunctionName(argument1, argument2, ...)
List - ANSWERA collection of values grouped together
Why use lists? - ANSWERWhen you have lots of variables that store related
information
List examples - ANSWERmyList = []
myList = [1,2,3,4]
myList = list('Hello World')
How to access values in a list - ANSWERlist[index]
List length - ANSWERlists start at index 0 and go up to the list length - 1
Tuples - ANSWERUse () rather than []
Are immutable while lists are mutable
Tuple example - ANSWERmyTuple = (1,2)
myTuple[0] = 1
Can you change the values in a tuple? - ANSWERNo, it's immutable
List of lists - ANSWER:my2DList = [[1,2,3],[4,5,6],[7,8,9]]
Referencing list of lists - ANSWERmy2DList[0] is [1,2,3]
my2DList[1][2] #would be 6
List1 + List2 - ANSWER[1.2] + [3,4] = [1,2,3,4]
3*List - ANSWER[1,2,1,2,1,2]
len(list) - ANSWERLength of the list
list.append(x) - ANSWERadd x to the end of the list
list.remove(x) - ANSWERremove x from the list
, del list[x] - ANSWERdeletes the value at position x
list.insert(index,value) - ANSWERinserts value at position index
Dictionaries - ANSWERsimilar to lists but have a key tied to every value instead of a
position
Keys - ANSWERanything that is immutable (ints, strings, tuples, etc)
Why use dictionaries? - ANSWERThere are two pieces of information tied together
continue - ANSWERCease executing the current repetition of a loop. If there's
another iteration of the loop, moves on to the next one
unpacking - ANSWERa process that performs multiple assignments at once, binding
comma-separated names on the left to the elements of a sequence on the right
enumerate() - ANSWERretrieves both the index and corresponding element value at
the same time,
nested loop - ANSWERa loop that appears as part of the body of another loop
Dictionary examples - ANSWERmyDictionary = {}
myDictionary = {'M':1, 'i':1, 's':2}
Assignments - ANSWERmyDictionary['a'] = 1
myDictionary['M'] = 1
key in dictionary - ANSWERChecks to see if a key is in the dictionary
loop - ANSWERexecutes the same code over and over again as long as some
condition is True
while loop - ANSWERexecutes a block of code as long as the loop's expression is
True
for loop - ANSWERa statement loops over each element in a container one at a
time, assigning the next element to a variable that can then be used in the loop body
range() - ANSWERgenerates a sequence of numbers, starting at zero and ending
before a value given inside the parentheses
break - ANSWERcauses an immediate exit of the loop
infinite loop - ANSWERa loop that will always execute because the loop's expression
is always True
Boolean - ANSWERTrue or False