Lists
Dictionaries
Functions
Random Topics
About Professor Zack
100

How do you initialize a new list?

new_list = [] 

or

new_list = list()

100

How do you initialize a new dictionary?

my_dict = {}

or

my_dict = dict()

100

What reserved word do you use to initialize a new function?


A. function my_func():

B. def my_func():

C. func my_func():

D. new my_func():

B.  def my_func():

100

True or False, the following code will throw an error...

x, y = 20, 30

print(x, y)

False, you can assign values to multiple variables on one line if separated by a ','

100

What type of music does Professor Zack like most?

Electronic 

Jazz

Rap

Rap

200

How do you add an element to the end of a list?

append

my_list.append( new_element )

200

Which way is correct when trying to access the value associated with 'my_key'?

my_dict['my_key'] 

or

my_dict{'my_key'}

or 

my_dict('my_key')

my_dict['my_key']
200

True or False, a function can only return one element?

False, they can return as many elements as you'd like. 

def my_func():

     return(x, y, z)

200

True or False, It is python convention to import the library in the line above where you are using the library.

False, it is python convention to import libraries at the very top or in the first lines of your python script. 

200

What are Professor Zacks favorite data structures?


Dictionaries

Lists

Sets

Tuples


[Lists]

300

What element of the list will this return 

my_list[-1]

The element at the end of the list. 

300

When iterating through a dictionary, what will the following 'i' value be, the dictionary keys or the values?

for i in my_dict:

    print(i)

the keys

300

A variable used inside a function becomes its...


A. Global Variable

B. Local Variable

C. Reference Variable

D. None of these

B. Local Variable

300

What will the following code produce?

my_string = 'A string'

x = list(my_string)

print(x)


A. ['A', ' ', 's', 't', 'r', 'i', 'n', 'g']

B. ['A', 'string']

C. ['A string']

D. None of the above

A.  ['A', ' ', 's', 't', 'r', 'i', 'n', 'g']

It will split the string into individual characters.


300

What does Professor Zack like the least?

Teaching

Pinball

Reading

Skateboarding

Surfing


Reading

400

If you have two lists of the same size, how do you iterate through both of them simultaneously? 

for i, j in zip( list_one, list_two):

      print(i, j)


400

True or False, values in the dictionary have to be unique.

False, the KEYS must be unique, the VALUES do not have to be unique. 

400

True or False, this is a valid way of constructing a function?

def my_func(x=5, y):

    return(x)

False, it will throw a error:

SyntaxError: non-default argument follows default argument.

valid way is 

def my_func(y, x=5):

       return(x)

400

What will the following code print?

my_string = 'abcdef'

print( my_string[0:-2] )

abcd

Because it will start at the 0th element and go to the -2 element which is d.

400

Which of the following behavior/s will get you on Zack's 'bad side'?


Interrupt him during class.

Using Google and ChatGPT. 

Not doing your HW.

DMing him on Slack. 



Not doing your HW.

500

Which one of these is not a valid list method... 

.index()

.length()

.insert()

.sort()


.length()

500

Which of these is not a valid method of dictionaries?

.values()

.pop()

.append()

.update()

.append()
500
True or False, Functions can be stored as an element in a list?

True. 

def my_func(x):

     return(x)

my_list = []

my_list[0] = my_func

500

True or False, The following is a valid way to construct a new class?

class Ball():

    def __init__(x, y):

        self.x = x

        self.y = y


        

False.  It is missing the 'self' variable in the init statement. 

class Ball():

    def __init__(self, x, y):

        self.x = x

        self.y = y


        

500

Which of the following jobs has Professor Zack NOT done. 


Financial Statistician at a Hedge Fund

Professional Poker Player

Data Scientist at Google

Line Chef at a Burrito Bar

Head Ocean Lifeguard

Editorial Graphic Designer

Director of Analytics at a Presidential Campaign 


Financial Statistician