| KC | Knowledge Check |
The Knowledge Check is intended to support learning and self-assessment. The questions highlight the key concepts of this unit and help prepare for the final examination.
The Knowledge Check is not graded.
1️⃣ Theory
Briefly explain the difference between:
- a list
- a NumPy array
2️⃣ Working with Lists
Assume:
my_list = [4, 7, 1, 9]
Write Python statements that:
- print the second element,
- print the length of the list,
- append the value
5to the end of the list.
3️⃣ List and Conditional Statement
Assume:
numbers = [12, 8, 22, 5]
Write Python statements that:
- replace the value
8with10, - remove the value
22from the list, - print the modified list.
4️⃣ Working with Arrays
Assume:
import numpy as np
a = np.array([3, 8, 5])
b = np.array([4, 7, 6])
Write a Python program that compares the first element of both arrays and prints the larger value.
5️⃣ Lists and Conditions
Assume:
colors = ["red", "green", "blue"]
Write a Python program that:
- checks whether the list contains three elements,
- prints
"List complete"if the condition is true, - otherwise prints
"List incomplete".
Discussion
The solutions will be discussed during the course session.