Introduction to Programming with Python
Day 2

David Garcia, University of Konstanz

Quiz I

  1. Write the output of the following code:
a = [1, 100]
b = a
b[0] = 0
print(a)
  1. Write the output of the following code:
a = [1, 2, 3]
c = [1, 2, 3]
print(a is c)
  1. Write the output of the following code:
a = [0,1,2]
for i in a:
  print(i)

Quiz II

  1. Evaluate whether each of the following code snippets produces an error. If it produces an error, briefly explain the reason why:
name = "dollhouse"
cats = 4
name_cats = name + cats
some_list = [2, 5, "Elephant", 6, 8.2, True]
print(some_list)
name = "dollhouse"
cats = 4
print(name, cats)
dollhouse = ['pandy', 'gabby', 'cakey', 'kitty', 'babybox']
print(dollhouse.index(1))
t = (1,2,3)
t.append(4)

Feedback on Day 1