Basic Python - Conditions

avatar

NaN years ago

Conditions are a way to control the flow of execution of the program, most often we apply conditions in the program to control the logic and achieve certain results. In Python we can achieve control by using the following statements:

  • If statement
  • Elif statement
  • If-else statement
  • Switch statement
  • Pass Statement
  • Break statement
  • Continue statement


Examples:

If x < 5:
  print(x)
  break
elif x < 10:
  print(x)
  continue
else
    pass

// Switch statement
switch(x):
  case x < 5:
    print(x)
    break
  case x < 10:
    print(x)
    break
  default:
    break
approvedApproved by experts
Advance Topics

Neuton's Mission

We are a team of young and enthusiastic people who are passionate about education and want to help students to learn the skills they need to succeed in life. If you want to support us, please join our community.

phonephonephonephonemail