Python

Python Conditional Statements

Any expression which returns either true or false that expression is known as condition.

Python Conditional Statements :

The Python Conditional statements are used to decide whether the code has to be execute or skip based on evaluation of the expression.

Elements of Conditional Statements :

While working with conditional statements we use two elements :

  1. Condition
  2. Block

Condition : Any expression which returns either true or false that expression is known as Condition.

Block : All the statements which are falling under the same space indentation is known as Block.

  • Blocks begins with when the indentation increases.
  • Blocks can contain multiple blocks.
  • Blocks ends when indentation decreases to zero or to a containing blocks indentation.

Typically Python supports three conditional statements, there are :

  1. if (or) simple if
  2. if else
  3. elif

Happy Learning :)

Found a mistake or something out of date? Tell us →

Written by

chandrashekhar

Founder of onlinetutorialspoint.com. Enterprise architect with 15+ years in healthcare technology, designing and running systems on AWS and Azure. Writes about building real things with AI, local AI hardware and cloud certifications.

Keep reading

Python

How to use Python Ternary Operator

In this article, we are going to discuss how to use python ternary operator and implementing nested-if-else with ternary operator along with basic examples Ternary Operators are also…

Ask a question or leave a comment