Lists
Dictionaries
NumPy Arrays
For loops
While loops
100

Given the list:

fruits = ['apple', 'orange', 'banana']

How would you access the item 'orange'?

fruits[1]

100
What is the output of farm_data['crop'] given:

farm_data = {'crop': 'corn', 'acres': 50}

'corn'

100

What value does this print?

animals_weights = [110, 140, 200]
print(animal_weights[1])

140

100

How many times will this for loop run?

for i in range(5):  
    print("Hello")

5

100

What is the variable i going to be at the end of the loop?

i = 0
while i < 3:
    i += 1

3

200

Fill in the blank to add a new animal to the end of the list:

animals = ['cow', 'pig']
animals.___('chicken')

animals.append('chicken')

200

Add a new key-value pair: 'milk_yield': 30 to the following dictionary:

cow = {'breed': 'Holstein'}

cow['milk_yield'] = 30

OR

cow.update({'milk_yield': 30})

OR 

kv_pair = {'milk_yield': 30}
cow.update(kv_pair)

200

Fill in the blank to calculate the average value of the array:

yields = np.array([150, 160, 155])
avg = np.___(yields)

np.mean(yields)

200

Fill in the blank to print each item of a list called crops:

for crop in ___:
    print(crop)

crops

200

Fill in the blank to print "Water level is low" until the level is 10: 

level = 5
            while level __ 10:
                                  print("Water level is low")
             level += 1

<=

300

What is the value and the type of ls_length if:

livestock = ['sheep', 'goats']
livestock.append('chickens')
ls_length = len(livestock)

ls_length is 3, type is 'int'

300

What is the output of this code?

animal_weights = {'cow': 500, 'pig': 200}
animal_weights['pig'] = 220
print(animal_weights['pig'])

220

300

How do you get the number of values in this numpy array?

temps = np.array([22, 23, 14]

len(temps)

300

What is the output of this code?

total = 0
for number in [10, 20, 30]:
    total += number
print(total)

60

300

How many times will "The tractor is running" be printed?

fuel = 5
          while fuel > 0:
                                 print("Tractor is running")
        fuel -= 2

1st) fuel = 5; -2
2nd) fuel = 3; -2
3rd) fuel = 1; -2 - DONE

400

What is the value of new_list?

daily_temps = [65, 70, 72, 75, 71, 68]
new_list = daily_temps[1:4]

[65, 70, 72]

400

What value is going to be printed?

temps = {'field1': 75, 'field2': 81, 'field3': 79}
my_temp = temps.get('field4', 79)

79

400

Resize/reshape this array to have 4 columns and 3 rows.

my_arr = np.array([1, 1, 1, 0, 0, 2, 0, 0, 0, 3, 3, 4])

new_arr = my_arr.reshape((4, 3))

OR

my_arr.resize((4, 3))

400

What is the final value of the variable count?

count = 0
for temp in [75, 80, 68, 85]:
    if temp > 70:
        count += 1

3

400

Find the issue with this code so that it counts from 1 to 5. 

count = 1
while count < 5:
    print(count)
    count += 1

Option 1) while count < 6


Option 2) Count starts from 0; and the print goes after the increment of count.


500

What is the output of this code?

weights = [3, 1, 5, 4, 6, 2, 10]
weights.remove(2)
print(weights)

[3, 1, 5, 4, 6, 10]

500

How do you remove 'field2' (and its value) from the following dictionary?

temps = {'field1': 75, 'field2': 81, 'field3': 79}

del temps['field2']

OR

var = temps.pop('field2')

500

Create a numpy array of 10 random values, in a range from 0 to 100.

rnd_arr = np.random.randint(0, 100, 10)

500

What is the output of this nested loop?

for animal in ['cow', 'pig']:
    for feed in ['hay', 'grain']:
               print(animal + ' eats ' + feed)

cow eats hay

cow eats grain

pig eats hay

pig eats grain

500

What will be the final value of population?

population = 10
growth = 2
          while population < 20:
                 population += growth

print(population)

20

M
e
n
u