Python Tutorial - python if else

how to make decisions on python by using if else conditions.

if (condition):
 statement1
  ....
else:
 statement2
  ....



mark = 20 + 20 + 30
if (mark > 60):
 print "you pass the exam with total mark:", mark
else:
 print "sorry, you mark:", mark


you can use the nested if construct.

if (condition_1):
 if (condition_2):
  statement2_1
  ....
  ....
 else:
  statement2_2
  ....
  ....

else:
 statement1_1
  ....
  ....



mark = 20 + 20 + 30

if (mark < 60):
 if (mark >= 50 ):
  print "Please check your mark with the teacher"

else:
 print "sorry, you mark:", mark









If this post was good and helpful for you, Please give it Like.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment