Python math
Python syntax
Bools and bits
Loops and lists
Potpourri
100
9 / 2

4.5

100

Which is an invalid variable name?

python

for

For

false


for

(false is a valid variable name... False is not)

100

Evaluate both:

False and False

False or (True or False)

False and False == False

False or (True or False) == True

100

What are the two prevailing types of loops in Python, and what are they each used for?

for loops: when the number of iterations is known

while loops: when the end condition is known

100

What data type is returned by the input() function?

A string

200

9 // 2

4

200

You can always use the comma to chain together variables in a print statement, like print("Your score is", score)

When can you also use a plus (+) to do the same?

When all variables involved are strings

200

What are the symbols for the following bitwise operations:

and

or

xor

not

left shift

and: &

or: |

xor: ^

not: ~

left shift: <<

200

How do lists differ from dictionaries?

Lists are indexed with integers, dictionaries can be indexed with strings or other data types.

200

What does the "break" keyword do in a loop?

Exits the loop even if it hasn't completed

300

2 ** 2 ** 3

256 (2 to the (2 to the 3))

300

A function is defined with the signature below:

def my_fun(var1, var2)

How should it be rewritten so that var2 has a default value of 6?

def my_fun(var1, var2=6)

300

6 in binary is 0000 0110. What is ~6 in binary?

1111 1001

300

What will print?

my_list = ['a', 'b', 'c', 'd', 'e']

print(my_list[::2])

['a', 'c', 'e']

300

What will be printed by the following line of code?

print("Z" * 3)

"ZZZ"

400

When dividing a float by an int, what data type will the result be?

float

400

What is printed by the following code snippet?

n = 3

n **= 2

print(n)

9

Same thing as:

n = 3

n = n ** 2

print(n)

400

Complete the xor table:

1 xor 1 ==

1 xor 0 ==

0 xor 1 ==

0 xor 0 ==

1 xor 1 == 0 (False)

1 xor 0 == 1 (True)

0 xor 1 == 1 (True)

0 xor 0 == 0 (False)

400

What's the difference between the .append() and .insert() methods for lists?

.append() adds an element to the end of the list, .insert() can add elements anywhere in a list

400

What does a "try/except" block allow a programmer to do?

Anticipate errors and prevent the program from crashing when they're encountered

500

3 % 17

3
500

What is the syntax for creating a tuple called "bear_creek" which holds the values "K-8" and "High School"?

bear_creek = ("K-8", "High School")

500

What effect does left shifting (<<) have on a number's value?

Multiplies the number by 2 for every bit shifted

500

In Python, a non-ordered, non-repetitive collection of items is known as what?

A set

500

Where did Python get its name?

Monty Python's Flying Circus