1. Home
  2. Data Science
  3. Python
  4. What is the purpose of the "if" statement in Python?

Added 27 Jan 2024

What is the purpose of the "if" statement in Python?

  1. To create a loop
  2. To define a function
  3. To perform conditional execution Correct answer
  4. To print a message

Correct answer

C. To perform conditional execution

16 views

MCQSEXAM

Explanation

The if statement performs conditional execution: its indented block runs only when the condition is true. It can be extended with elif and else for additional branches.

Loops are created with for and while, and functions with def.

Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs