| 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️⃣ Conditional Statements
What is the purpose of an if statement in Python?
Explain in your own words.
2️⃣ Multiple Choice
Which of the following statements are correct?
A) An if statement can never be used without else.
B) if, elif, and else can be used to check different conditions.
C) More than one elif statement can be used in the same conditional structure.
D) Conditions in an if statement must evaluate to either True or False.
Select all correct answers.
3️⃣ Writing an If Statement
Assume the following variable:
age = 21
Write a Python if statement that checks whether a person is at least 18 years old.
If the condition is true, print:
Adult
4️⃣ If – Elif – Else
Assume:
score = 75
Write a Python program that prints:
"Passed"if the score is 50 or higher"Failed"otherwise
5️⃣ If – Elif – Else
Assume:
temperature = 18
Write a Python program that prints:
"Cold"if the temperature is below 10"Mild"if the temperature is between 10 and 20"Warm"if the temperature is above 20
Discussion
The solutions will be discussed during the course session.