Pract4
Pract4
1)IF statement
Code:
i=10
if(i > 20):
print ("10 is less than 20")
print ("We are Not in if ")
Output:
2) If Else Statement
Code:
i=10;
if(i<20):
print ("i is smaller than 20")
else:
print ("i is greater than 25")
Output:
3) Nested IF statement
Code:
i =10
if(i ==10):
if(i < 20):
print("i is smaller than 20")
if (i < 15):
print ("i is smaller than 15 too")
else:
print ("i is greater than 15")
Output:
Subject: PWP[22616]
Practical No. 4:Use of condition statements :If,IfElse,NestedIf
Name: Ritesh Doibale Roll no:41
XI. Exercise
Q1- Write a program to check whether a number is even or odd
-------------------------------------------------( Program Code )------------------------------------------------------
print("Finding Even or Odd")
i=int(input("Enter the number :"))
if i%2==0 :
print("Even")
else:
print("Odd")
-----------------------------------------------( Program Output )------------------------------------------------------
Q3- Write a program to check the largest number among the three numbers
-------------------------------------------------( Program Code )------------------------------------------------------
i=int(input("Enter the first number:"))
j=int(input("Enter the Second number:"))
k=int(input("Enter the Third number:"))
if i>j and i>k:
print("First number is greator")
if j>i and j>k :
print("Second number is greator")
else :
print("Third number is greator")
Subject: PWP[22616]
Practical No. 4:Use of condition statements :If,IfElse,NestedIf
Name: Ritesh Doibale Roll no:41
-----------------------------------------------( Program Output )------------------------------------------------------
Output: