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

Added 10 Feb 2024

What is the purpose of the 'if' statement in Python program flow?

  1. To create loops
  2. To define functions
  3. To handle conditions and make decisions Correct answer
  4. To import external libraries

Correct answer

C. To handle conditions and make decisions

16 views

MCQSEXAM

Explanation

The 'if' statement in Python is used to introduce conditional logic, allowing the program to make decisions based on whether a given condition is true or false. It plays a crucial role in controlling the flow of execution by executing certain code blocks based on the evaluation of conditions.

Reference

https://www.w3schools.com/python/default.asp

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