1 - An operator able to check whether two values are not equal is coded as:
Solution: !=
2 - How many stars will the following snippet send to the console?
i = 2
while i >=0:
print("*")
i -= 2
Solution: two
3 - How many hashes will the following snippet send to the console?
for i in range (-1,1)
print("#")
Solution: two.
4 - What value will be assigned to x variable?
z = 10
y = 0
x = z > y or z == y
Solution: True
5 - What is the output of the following code?
lst = [3, 1, -1]
lst[-1] = lst[-2]
print(lst)
Solution: [3, 1, 1]
Second Assignment:
vals = [0, 1, 2]
vals[0], vals[1] = vals[1], vals[2]
Solution: doesn't change the list's length
7 - Take a look at the snippet and choose one of the following statements which is true:
nums = [ ]
vals = nums
vals.append(1)
Solution: nums and vals are the same length
8 - Take a look at the snippet and choose one of the following statements which is true:
nums = [ ]
vals = nums[:]
vals.append(1)
Solution: vals is longer than nums
9 - How many elements does the 1 list contain?
1 = [0 for i in range(1, 3)]
Solution: two
10 - What is the output of the following snippet?
lst = [0, 1, 2, 3]
x = 1
for elem in lst:
x *= elem
print(x)
Solution: 0