Iterations
Logic
Comprehensions
Functions
Trivia
100

The 2 main keywords to disrupt iterative execution

What is continue and break?

100

Given a list ll, if we wanted to pop out each 0th element and do something with it, the reason why while ll: would work to pop all of them out is

What is ...
while ll and if ll is the same as asking while ll is not empty
By default, an empty sequence will be interpreted as a False boolean and True if non-empty

100

The 3 common comprehension datatypes

What is list, set, and dictionary?

100

As many parts of a function as you can name

What is ...

definition, function name, parameters, colon, function signature, indentation, code block

200

The while loop conditional for i when we intend on comparing pairs of elements

Plus, the for loop expression for the same

What is ...

while i < len(sequence)-1

for i in range(len(sequence)-1)

200

If you had a program to find the max/biggest element in a list by having a variable that stores the current best and compares that to the current element, what could you initialize it to first

What is ...

The first element ll[0], float('inf'), None

200

Comprehension expression + function for returning the string of all vowels (duplicates considered too) given a string s

What is ...

"".join([char for char in s if char in "aeiouAEIOU"])

200

Places you have heard the words inclusion, exclusion, step, and their meanings

What is ...

Up to you but commonly in ranges

Start is inclusive/included, end is exclusive/excluded, step is in what sense do you get the next element (step=1, step=2, step=-1)

200

The attribute that makes a void function void

What is no return?

300

3 differences between for loops and while loops in general and/or relation to a sequence and its elements

What is ...

For accesses elements directly but while does it indirectly with the use of index pointer i

Bounded vs unbounded, ie. you do or don't know exactly how many times the iteration is going to run

Up to my discretion :)

300

Give as many logic keywords as you can

What is ...

if elif else and or not True False in is

300

Any objective to semi-subjective advantage of comprehensions over other iterative forms

What is ...

Concise, creates new datastructure, etc. (up to my discretion)

300

As many built in functions (NOT methods) as you can name

What is ...

max, min, len, all, any, bool, dict, int, str, float, input, isinstance, list, map, open, print, set, range, sorted, sum, tuple, type, etc.

300

The meaning of syntax and semantics

Give me a syntax error and a semantic error

What is the grammar of code and the meaning of code

400

A for loop code block for reversing a sequence without usage of ANY methods

What is ...

ans = []

for element in sequence:

ans = [element] + ans

400

The value and datatype of: (-2**2 + 3 * 3)/2 + (not False or True and True)

What is 3.5 and float?

400

The comprehension format for when we want to use an if, an elif, and an else

What is ...

[x1 if conditional1 else x2 if conditional2 else x3]

400

The function signature for a function that

(1) has a list parameter ll

(2) has a step parameter that is an integer, if none is given assume step is 1

(3) an args parameter which collects excess input data

(4) a kwargs parameter which collects all excess input data that is attached to a variable

What is ...

def func(ll, step=1, *args, **kwargs)

500

In a game of blackjack, given player1_score, player2_score, player1_stand (bool), player2_stand (bool), deck_isempty (bool), the conditional for the while loop that decides if the game continues or if a winner has to be declared

What is ...

while player1_score < 22 and player2_score < 22 and not (player1_stand and player2_stand) and not deck_isempty:

500

(True and not False) or (not (False or (not True and (False or True))) and (True or not (False and True))) and (not (False or (not (True and False) and True)) or (False and True) or (not False and True))

What is True?

Disclaimer, this is very unlikely and the point is to keep tabs on progress and to take things one at a time (ie. one bracket at a time)

500

The comprehension expression for returning all possible pair combinations of a list of numbers ll, plus the reason an expression for all unique pairings can't be done

What is ...

[[x,y] for x in ll for y in ll]

Unique cannot be done since you cannot check if pairing is already in the datastructure since it's not generated piece by piece, it's generated as a whole

500

Write a function that accepts an input ll filled with numbers and returns the mean, median, and variance

Mean is the average

Median is the middle number in a sorted sequence of numbers (assume odd length list)

Variance is (num-mean)^2 for all num in ll and all of it divided by length-1

What is ...

def func(ll):

ll.sort()

mean = sum(ll)/len(ll)

median = ll[len(ll)//2]