Stats

174 Contributors: 26 Tuesday, May 16, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Conditionals

Introduction

Conditional expressions, involving keywords such as if, elif, and else, provide Python programs with the ability to perform different actions depending on a boolean condition: True or False. This section covers the use of Python conditionals, boolean logic, and ternary statements.

Syntax

  • <expression> if <conditional> else <expression> # Ternary Operator

Related Examples