Skip to content

Files

Latest commit

f7b3c2f · Jun 18, 2024

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 18, 2024
Jan 4, 2024

Conditional Statements in python

  1. if statement: Executes a block of code if the condition is true.
if condition:
    # code to execute if condition is true
  1. elif statement: Stands for "else if" and allows multiple conditions to be checked sequentially after an initial if statement.
if condition1:
    # code to execute if condition1 is true
elif condition2:
    # code to execute if condition2 is true
  1. else statement: Executes a block of code if none of the preceding conditions are true.
if condition1:
    # code to execute if condition1 is true
elif condition2:
    # code to execute if condition2 is true
else:
    # code to execute if none of the above conditions are true