Decision making statements in programming languages decides the direction of flow of program execution. Decision making statements available in python are:

    - if<condition>

    - if<condition>..else
    - nested If
    - if<cond>...elif<cond>..elif<cond>..else (if..elif ladder)

if statement

  syntax-

  if <condition>:

     stmt1

     stmt2

       .

       .

       .

     stmtn


yourFavLang = input("enter your favourite language\n") 

if yourFavLang == 'python':

   print("Good Choice")

   print("Best Selection")


print("continue")


if..else statement

  syntax-

  if <condition>:

     stmt1

     stmt2

       .

       .

       .

     stmtn

  else:

     stmt1

     stmt2

       .

       .

       .

     stmtn

#posi and neg number

#practical and Theorymark

if yourFavLang == "Python":

   print("Good Choice") #whenover condition is true this block will get execute.

   print("Best Selection")

else: #whenover if condition is false this block will get execute.

   print("You are not choose python")

print("continue")


Nested if

  

if..elif..elif..else statement

 syntax-

if(Condition1):

     stmt1

     stmt2..
    stmtn

elif(Condition2):

      stmt1

     stmt2
    stmtn

else:

      stmt1

     Stmt2..
    Stmtn
#practicalAndTheoryMark
#Percentage grade

percentage = int(input("Enter your percentage"))

if percentage >= 35 and percentage <= 50:

  print("Grade C",)

elif percentage > 50 and percentage <= 60:

  print("Grade B")

elif percentage > 60 and percentage <= 75:

  print("Grade A")

elif percentage > 60 and percentage <= 75:

  print("Destination")

else:

  print("Failed")


Categories: Python Tags: #Python,

Comments