Python If Else Statement

 

Three types of If statement:

1) If Statement

   num = int(input("enter the number:"))
   if num%2 == 0:
      print("The Given number is an even number")


Program to print the largest of the three numbers.
  
a = int (input("Enter a: "));
b = int (input("Enter b: "));
c = int (input("Enter c: "));
if a>b and a>c:
  print ("From the above three numbers given a is largest");
 
if b>a and b>c:
  print ("From the above three numbers given b is largest");
 
if c>a and c>b:
  print ("From the above three numbers given c is largest");  

2) If- else statement:

  age = int (input("Enter your age: "))
  if age>=18:
     print("You are eligible to vote !!");
else:
     print("Sorry! you have to wait !!");

3)Elif Statement:
    
number = int(input("Enter the number?"))
if number==10:
   print("The given number is equals to 10")
elif number==50:
   print("The given number is equal to 50");
elif number==100:
   print("The given number is equal to 100");
else:
   print("The given number is not equal to 10, 50 or 100");
     
      

Comments

Popular posts from this blog

How to Run Python in MS Visual Studio Code

Python Strings

Python Loop Statements