Knowledge check

Python Programming for Application Development: Practical Python for Technology Professionals
Lesson Content
0% Complete

Q1. Which keyword is used to create a decision branch in Python?

  • loop
  • if
  • case
  • switch
Reveal answer

Answer: if
Python uses if, elif, and else to make decisions based on conditions.


Q2. The operator == checks whether two values are equal.

  • True
  • False
Reveal answer

Answer: True
== is a comparison operator used to test equality.


Q3. What is the main purpose of an else block?

  • To repeat code forever
  • To handle the default case when earlier conditions are false
  • To store a variable
  • To create a list
Reveal answer

Answer: To handle the default case when earlier conditions are false
else provides a fallback path when no earlier condition matched.