

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is basic syntax of Python if...else statement?
In Python, the conditional statement if can have an optional else clause. The indented block after if statement is executed when logical expression in front of if is true. If an alternative action is sought to be taken by program if the expression is false, it is given as another indented block after else. The usage is described below −
if expr==True: #stmt1 #stmt2 else: #stmt3 #stmt4
Here first block containing stmt1 and stmt2 will be executed if expr is true. Whereas second block containing stmt3 and stmt4 will be executed if expr is false
- Related Questions & Answers
- What is the syntax of Python if...elif...else statement?
- What is correct syntax of Python if statement?
- What is if...else if... statement in JavaScript?
- What is basic syntax of Python for Loops?
- What is the if...else statement in JavaScript?
- Java if-else statement
- Java if-else-if ladder statement
- Java if-then-else statement
- IF ELSE statement in a MySQL Statement?
- What is the resemblance of COALESCE() function with IF-THEN-ELSE statement?
- What is the basic syntax to access Python Dictionary Elements?
- What is the ‘if...else if...else’ statement in Java and how to use it?
- How to indent an if...else statement in Python?
- Explain if-else statement in C language
- Explain Nested if-else statement in C language
Advertisements