| KC | Knowledge Check |
The Knowledge Check is intended to support learning and self-assessment.
The Knowledge Check is not graded.
1️⃣ Multiple Choice
Given:
age = 25
price = 4.99
name = "Anna"
Which statement is correct?
A) age is a string
B) price is a float
C) name is a list
D) age is a boolean
Select the correct answer.
2️⃣ Multiple Choice
Given:
numbers = [5, 10, 15]
Which statement prints the second element of the list?
A)
numbers[0]
B)
numbers[1]
C)
numbers[2]
D)
numbers[3]
Select the correct answer.
3️⃣ Multiple Choice
Given:
score = 75
Which output is produced?
if score >= 50:
print("Passed")
else:
print("Failed")
A) Failed
B) Passed
C) Error
D) No output
Select the correct answer.
4️⃣ Multiple Choice
What is printed by the following code?
for i in range(1, 4):
print(i)
A)
1
2
3
B)
1
2
3
4
C)
0
1
2
3
D)
1
2
Select the correct answer.
5️⃣ Multiple Choice
Given:
text = "Python"
What is the result of:
print(text[:3])
A)
Pyt
B)
hon
C)
Python
D)
yth
Select the correct answer.
6️⃣ Writing Python Code
Create a variable named temperature and assign it the value 18.
Write a Python program that:
- prints
"Cold"if the temperature is below 10, - prints
"Mild"if the temperature is between 10 and 20, - prints
"Warm"if the temperature is above 20.
7️⃣ Writing Python Code
Assume:
numbers = [4, 7, 2, 9]
Write Python statements that:
- append the value
5to the list, - remove the value
2, - print the modified list.
8️⃣ Writing Python Code
Write a Python program that:
- uses a
forloop, - prints all numbers from 1 to 10,
- prints only the even numbers.
Expected output:
2
4
6
8
10
Discussion
The solutions will be discussed during the course session.