0% found this document useful (0 votes)
4 views

python programming II _221214_095049

Uploaded by

murarilal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

python programming II _221214_095049

Uploaded by

murarilal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

9)WAP to find maximum of three numbers

a=int(input('enter I number'))
b=int(input ('enter II number'))
c=int(input ('enter III number'))
if(a>b)and(a>c):
print('the greatest number is',a)
elif(b>a)and(b>c):
print('the greatest number is',b)
elif(c>a)and(c>b):
print('the greatest number is',c)
else:
print('all the 3nos.are equal')
10)WAP to check eligibility to vote
age=int(input('enter your age'))
if age>=18:
print ('you are an adult and you can go for voting')
else:
print ('sorry! you are not an adult and ineligible for
voting')
11)WAP to check whether given no. is even or odd

a=int(input('enter the number'))


if(a%2==0):
print (a,'is even')
else:
print (a,'is odd')
12)WAP to display grades according to percentage (grade sheet
program)
names=input("Enter the name of student")
m=float(input("Enter the marks secured in Mathematics out of 100:"))
e=float(input("Enter the marks secured in English out of 100:"))
h=float(input("Enter the marks secured in Hindi out of 100:"))
so=float(input("Enter the marks secured in Social Science out of 100:"))
sci=float(input("Enter the marks secured in Science out of 100:"))
score=m+e+h+so+sci
percent=(score/500)*100
print("Hello to",names,"!Your score card:")
print("The total of student score:",score)
print("The percentage obtained by student:",percent,"%")
if(percent>80)and(percent<=100):
print("Grade of",names,":A")
elif(percent>60)and(percent<=80):
print("Grade of",names,":B")
elif(percent>40)and(percent<=60):
print("Grade of",names,":C")
elif(percent>35)and(percent<=40):
print("Grade of",names,":D")
else:
print("Better Luck next time")
13)Total amount bill with item name, price per unit and
quantity.
state=input("Enter the state of Item purchased(lt/kg)")
item=input("enter the name of Item purchased")
quantity=float(input("enter the quantity"))
if(state=="lt"):
price=float(input("Enter the cost of 1 litre of purchased item"))
bill=quantity*price
print("The bill amount is",bill)
elif(state=="kg"):
price=float(input("Enter the cost of 1 kg of purchased item"))
bill=quantity*price
print("The bill amount is",bill)
else:
print("Invalid data")
14)To make calculator by character selection of operators i.e
+,×,÷,-.
choice=input("Choose the arithmetic operation(+,-,*,/)")
num1=float(input("enter the I number"))
num2=float(input("enter the II number"))
if(choice=="+"):
total=num1+num2
print("The total is",total)
elif(choice=="-"):
diff=num1-num2
print("The difference is",diff)
elif(choice=="*"):
prod=num1*num2
print("The product is",prod)
elif(choice=="/"):
quo=num1/num2
print("The quotient is",quo)
else:
print("Invalid operator Entered")
15)To calculate the area of figures according to user
choice.(1. Square 2. Rectangle 3. Triangle 4.Circle)
choice=input("Choose the 2D shape(1.square, 2.rectangle,
3.triangle,4.circle)")
if(choice=="square"):
side=float(input("Enter the side length of square"))
areasq=side**2
peris=4*side
print("the area of square=",areasq)
print("the perimeter of square=",peris)
elif(choice=="rectangle"):
length=float(input("Enter the length of rectangle"))
width=float(input("Enter the breadth of rectangle"))
arear=length*width
perir=2*(length+width)
print("the area of rectangle=",arear)
print("the perimeter of rectangle=",perir)
elif(choice=="triangle"):
base=float(input("Enter the base of triangle"))
height=float(input("Enter the height of triangle"))
Iside=float(input("Enter the length of I side of triangle"))
IIside=float(input("Enter the length of II side of triangle"))
areat=0.5*base*height
perit= base+Iside+IIside
print("the area of triangle=",areat)
print("the perimeter of triangle=",perit)
elif(choice=="circle"):
radius=float(input("Enter the radius of circle"))
areacr=3.14*radius**2
circum=2*3.14*radius
print("the area of circle=",areacr)
print("the circumference of circle=",circum)
else:
print("invalid choice entered")
16)Program to find the greatest no. among 4 numbers.

a=int(input('enter I number'))
b=int(input ('enter II number'))
c=int(input ('enter III number'))
d=int(input ('enter IV number'))
if(a>b)and(a>c)and(a>d):
print('the greatest number is',a)
elif(b>a)and(b>c)and(b>d):
print('the greatest number is',b)
elif(c>a)and(c>b)and(c>d):
print('the greatest number is',c)
elif(d>a)and(d>b)and(d>c):
print('the greatest number is',d)
else:
print('all the 4nos.are equal')
17.Enter 2 numbers and check whether first number is
divisible by second number.

a=int(input('enter I number'))
b=int(input ('enter II number'))
if(a%b==0):
print(a,"is divisible by",b)
else:
print(a,"is not divisible by",b)
18.To calculate restaurant bill on choice of item.(1. Pizza 2.
Noodles 3. Burger)
choice=input("Choose the dish(1.Pizza:149Rs. 2.Noodles:49 Rs.
3.Burger:99 Rs):")
if(choice=="Pizza" or choice=="pizza"):
quantity=int(input("enter the quantity of the Pizza Purchased:"))
bill=quantity*149
print("bill amount to be paid:",bill,"Rs.")
elif(choice=="Noodles" or choice=="noodles"):
quantity=int(input("enter the quantity of the Noodles Purchased:"))
bill=quantity*49
print("bill amount to be paid:",bill,"Rs.")
elif(choice=="Burger" or choice=="burger"):
quantity=int(input("enter the quantity of the Burger Purchased:"))
bill=quantity*99
print("bill amount to be paid:",bill,"Rs.")
else:
print("dish not in menu card")
19.To display name of the day according to user choice(1.
Monday 2.Tuesday 3. Wednesday.......)
choice=int(input("Choose the Day (1.Monday. 2.Tuesday. 3.Wednesday
4.Thursday 5.Friday 6.Weekend Begins):"))
if(choice==1):
print("Monday")
elif(choice==2):
print("Tuesday")
elif(choice==3):
print("Wednesday")
elif(choice==4):
print("Thursday")
elif(choice==5):
print("Friday")
elif(choice==6):
print("Weekend Begins")
else:
print("Not a week day")
20. Check whether a character is a capital, small letter or a
number.

choice=input("Enter one Character")


if(choice>="A" and choice<="Z"):
print("Capital Letter has been entered")
elif(choice>="a" and choice<="z"):
print("Small Letter has been entered")
elif(choice>="0" and choice<="9"):
print("A digit has been entered")
else:
print("Special Symbol")
Programs
1. To find sum of two numbers.
2. To find product of two numbers.
3. To find the difference between two numbers.
4. Division
5. To find the area and perimeter of rectangle and triangle.
6. To find the area and perimeter of square and circle.
7. Display Student’s score and to find the percentage.
8. To find the greatest number among two numbers.
9. To find the greatest number among three numbers.
10.Simple Interest
11. Swapping without using III variable.
12.Swapping using III variable.
13.TSA and volume of 3D shapes.
14.Temperature conversion
15.To calculate grade according to percent obtained by a student.
16.To check whether a person is eligible for vote.
17.To find whether a number is even or odd.
18. Total amount bill with item name, price per unit and
quantity.
19.To make calculator by character selection of operators i.e
+,×,÷,-.
20. To calculate the area of figures according to user choice.(1.
Square 2. Rectangle 3. Circle)
21. Program to find the greatest no. among 4 numbers.
22. Enter 2 numbers and check whether first number is
divisible by second number.
23. To calculate restaurant bill on choice of item.(1. Pizza 2.
Noodles 3. Burger)
24. To display name of the day according to user choice(1.
Monday 2.Tuesday 3. Wednesday.......)
25. Check whether a character is a capital, small letter or a
number.

You might also like