pe1 module 3
MODULE 3 TEST
Well done! You've reached the end of Module 3 and completed a major milestone in your Python programming education. Here's a short summary of the topic areas you've covered in Module 3:
- Boolean values to compare different values and control the execution paths using the if and if-else instructions;
- the utilization of loops (while and for) and how to control their behavior using the break and continue instructions;
- the difference between logical and bitwise operations;
- the concept of lists and list processing, including the iteration provided by the for loop, and slicing;
- the idea of multi-dimensional arrays.
You are now ready to take the module test, which will both help you gauge what you've learned so far.
The following test is based on what you have just learned. There are twenty questions in total and you need to score at least 70% to pass.
Good luck!
An operator able to check whether two values are equal is coded as:
The value eventually assigned to x is equal to:
123x = 1x = x == x
How many stars (
12345i = 0while i <= 3 : i += 2 print("*")
How many stars (
1234567i = 0while i <= 5 : i += 1 if i % 2 == 0: break print("*")
How many hashes (
12345for i in range(1): print("#")else: print("#")
How many hashes (
1234567var = 0while var < 6: var += 1 if var % 2 == 0: continue print("#")
How many hashes (
12345var = 1while var < 10: print("#") var = var << 1
What value will be assigned to the
1234z = 10y = 0x = y < z and z > y or y > z and z < y
What is the output of the following snippet?
12345678a = 1b = 0c = a & bd = a | be = a ^ b print(c + d + e)
What is the output of the following snippet?
123my_list = [3, 1, -2]print(my_list[my_list[-1]])
What is the output of the following snippet?
123my_list = [1, 2, 3, 4]print(my_list[-3:-2])
The second assignment:
123vals = [0, 1, 2]vals[0], vals[2] = vals[2], vals[0]
After execution of the following snippet, the sum of all
1234vals = [0, 1, 2]vals.insert(0, 1)del vals[1]
Take a look at the snippet, and choose the true statements: (Select two answers)
1234nums = [1, 2, 3]vals = numsdel vals[1:2]
Which of the following sentences are true? (Select two answers)
123nums = [1, 2, 3]vals = nums[-1:-2]
What is the output of the following snippet?
123456my_list_1 = [1, 2, 3]my_list_2 = []for v in my_list_1: my_list_2.insert(0, v)print(my_list_2)
What is the output of the following snippet?
12345my_list = [1, 2, 3]for v in range(len(my_list)): my_list.insert(1, my_list[v])print(my_list)
How many elements does the
12my_list = [i for i in range(-1, 2)]
What is the output of the following snippet?
123456t = [[3-i for i in range (3)] for j in range (3)]s = 0for i in range(3): s += t[i][i]print(s)
What is the output of the following snippet?
123my_list = [[0, 1, 2, 3] for i in range(2)]print(my_list[2][0])
Comments
Post a Comment