A method to solve problems through repetition of a consistent set of steps.
What is an Algorithm?
The final value of x after these operations:
x = 3
y = 9
y = y + x
x = y / x
x = x**2
What is 16?
What is a for loop?
(same should check if y and x are equivalent)
def same(x, y):
if _____:
return True
else:
return False
x == y
The name for the result of any series of operations that results in only two possible outcomes; often denoted with True or False.
What is a Boolean Expression?
An algorithm that continually adds to a value or container.
What is an Accumulator Pattern?
The value of y after completion of the loop.
x = 7
y = 0
while y < x:
y += 2
x -= 1
What is 6?
A form of loop that continues or terminates based on a Boolean expression.
What is a while loop?
(remainder should return what remains after integer dividing y from x)
def remainder(x: int, y: int):
return _____
x % y
The term for a defined placeholder for a variable to be passed in when calling a function.
What is a Parameter(or Formal Argument)?
An algorithm that tends a set of points toward the centers of a greater set of points and determines subsets of the greater set of points.
What is k-means Cluster?
The value printed to shell from the following code:
x = [ 'B', 25, [ 'a', 'e', 'i', 'o', 'u']]
print( x[0] + (3 * x[2][3]))
What is Booo?
An indexable container which holds all its elements in order, but cannot change in size or otherwise be modified.
What is a tuple?
(assume no floats)
def do_stuff(x:___, y:___, z:___)_____:
q = x * y
m = z + '2'
return {m:q}
int ; int ; str ; -> dict[str:int]
The ability to modify an object without needing to reassign or recreate it.
What is Mutable?
The process of having a function call itself until it reaches a base case where it stops and returns.
What is Recursion?
The return of the following code:
x = [(2 - i) for i in range(5)]
print(sum(x))
What is 0?
An unordered container that is syntactically defined with '{}' and stores elements in pairs.
What is a dictionary?
(Factorial is: 4! = 1 * 2 * 3 * 4)
def factorial(num):
if num == 1:
return 1
else:
return ____
num * factorial(num - 1)
A function that specifically is called on an object of some sort, noted by the '.' that follows the object it is being called on.
What is a Method?
A process that logically divides a organized list in half until finding a desired value.
What is Binary Search?
The return of the following code:
foo = {str(x): x**2 for x in [1,2,3,4]}
for a, b in foo.items():
print(f"{a} : " , b - int(a))
1 : 0
2 : 2
3 : 6
4 : 12
The generic term for the process of filling a container by a loop process.
What is Comprehension?
(the following function will return a list with two elements , one of which is y and the other is a repetition of y and must use both x and y. eg: x = 3, y = 'qw' result: ['qw', 'qwqwqw'])
def my_func(x:int, y:str) -> list[str]:
m = []
m._____
m._____
return m
.append(y) ; .append(y*x)
A separate file of code that can be added in to the current file in order to use its functions.
What is a Module?