0% found this document useful (0 votes)
23 views4 pages

Pract4

Uploaded by

Ritesh Doibale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Pract4

Uploaded by

Ritesh Doibale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Subject: PWP[22616]

Practical No. 4:Use of condition statements :If,IfElse,NestedIf


Name: Ritesh Doibale Roll no:41
Practical Code:

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 )------------------------------------------------------

Q2- Write a program to find out absolute value of an input number


-------------------------------------------------( Program Code )------------------------------------------------------
import math
i=float(input("Enter the number :"))
print("absolute number of {0} is {1}".format(i,math.floor(i)))

-----------------------------------------------( 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 )------------------------------------------------------

Q4 - Write a program to check if the input year is a leap year of not


-------------------------------------------------( Program Code )------------------------------------------------------
i=int(input("Enter the year : "))
if i%4==0 :
print("year is leap")
else:
print("year is not leap")

-----------------------------------------------( Program Output )------------------------------------------------------

Q5 - Write a program to check if a Number is Positive, Negative or Zero


-------------------------------------------------( Program Code )------------------------------------------------------
i=int(input("Enter the number: "))
if i==0:
print("number is zero")
if i>0:
print("number is Positive greator than Zero")
else:
print("number is Negative smaller than Zero")
-----------------------------------------------( Program Output )------------------------------------------------------
Subject: PWP[22616]
Practical No. 4:Use of condition statements :If,IfElse,NestedIf
Name: Ritesh Doibale Roll no:41
Q6 - Write a program that takes the marks of 5 subjects and displays the grade.
-------------------------------------------------( Program Code )------------------------------------------------------
print("Enter the marks below 100")
a=float(input("Enter the marks of subject 1 :"))
b=float(input("Enter the marks of subject 2 :"))
c=float(input("Enter the marks of subject 3 :"))
d=float(input("Enter the marks of subject 4 :"))
e=float(input("Enter the marks of subject 5 :"))
avg=(a+b+c+d+e)/5
if avg>=90:
print(" A grade ")
elif avg>=80 and avg<90:
print(" B grade ")
elif avg>=70 and avg<80:
print(" C grade ")
elif avg>=60 and avg<70:
print(" D grade ")
elif avg>=50 and avg<60:
print(" E grade ")
elif avg>=40 and avg<50:
print(" F grade ")
else:
print(" You Failed ")

Output:

You might also like