Python Programs
Python Programs
Hello world
print(100+200)
300
n1=190
n2=79798
n3=n1+n2
print('SUM of the two numbers=',n3)
Enter name:Smitha
The entered name is Smitha
Code Text
# Wap to accept name of a student,class and section and print the same in multiple lines
n=input('Enter name')
c=input('Enter class')
s=input('Enter section')
print('Entered name is',n)
print('Entered class is',c)
print('Entered section is',s)
Enter nameSmitha
Enter class11
Enter sectionA
Entered name is Smitha
Entered class is 11
Entered section is A
Enter radius1
AREA= 3.14
CIRCUMFERENCE= 6.28
#WAP to accept length and breadth of rectangle and find perimeter and area
l=float(input('Enter length:'))
b=float(input('Enter breadth:'))
area=l*b
p=2*(l+b)
print('AREA=',area)
print('PERIMETER=',p)
Enter length:10
Enter breadth:2
AREA= 20.0
PERIMETER= 24.0
#WAP to accept marks of 5 subjects(Eng,Maths,Sci,SSt,lang2) and compute total and average marks.
eng=float(input('enter eng marks'))
Maths=float(input('Enter maths marks'))
Sci=float(input('Enter sci marks'))
sst=float(input('Enter sst marks'))
lang2=float(input('Enter 2lang marks'))
t=eng+Maths+Sci+sst+lang2
a=t/5
print('TOTAL=',t)
print('AVERAGE=',a)
#WAP to accept age of a person and check for his voting eligibility
p g p g g y
age=float(input('Enter age'))
if age>=18:
print('The person is eligible to vote')
else:
print('The person is not eligible to vote')
Enter age12
The person is not eligible to vote
#WAP to accept percentage of a student and check for his/her scholarship eligibility.
#percentage above 98-eligible for scholarship,otherwise not eligible
p=float(input('Enter percentage:'))
if p>98:
print('Eligible for scholarship')
else:
print('Not eligible for scholarship')
#WAP to accept marks of 3 subjects (eng,maths,sci)and compute total.if total above 150 he is declared
#Otherwise fail.Print appropriate messages
m1=float(input('Enter eng marks'))
m2=float(input('Enter maths marks'))
m3=float(input('Enter sci marks'))
t=m1+m2+m3
print('TOTAL=',t)
if t>150:
print('PASS!!!')
else:
print('FAIL!!!')
Enter number-20
No. is negative
'''WAP to accept average marks scored by a student and implement the following:
Marks Grade
>90 A+
80-90 A
60-80 B
<60 C'''
AvgMarks=float(input('Enter average marks')) #accepting average marks
if AvgMarks>90: #checking whether marks is greater than 90
print('GRADE =A+') #if so,A+ will be displayed
elif AvgMarks>=80 and AvgMarks<=90: #checking whether marks between 80 and 90
print('GRADE=A') #Grade A will be displayed
elif AvgMarks>=60 and AvgMarks<80: #checking whether marks between 60-80
print('GRADE=B') #Grade B is displayed
elif AvgMarks<60: #checking whether marks less than 60
print('GRADE=C') #Grade c is displayed
'''WAP to accept total bill of a shop and give discounts as per the given criteria
Bill amount discount%
above 10000 10%
5000-10000 5%
less than 5000 2%
display the discount amount and final net amount'''
bill=float(input('Enter bill amount'))
if bill>10000:
d=0.1*bill
elif bill>=5000 and bill<=10000:
d=0.05*bill
elif bill<5000:
d=0.02*bill
print('discount amount=',d)
net=bill-d
print('net amount=',net)
'''WAP to accept total bill of a shop and give discounts as per the given criteria
Mode of payment discount%
cash 10%
credit card No discount
Debit card 5%
display the discount amount and final net amount'''
bill=float(input('Enter bill amount'))
mode=input('enter c for cash/cr for credit card/d for debit card:')
if mode=='c':
d=0.1*bill
elif mode=='cr':
d=0
elif mode=='d':
d=0.05*bill
print('discount amount=',d)
net=bill-d
print('net amount=',net)
#Write a menu driven program to accept a choice(1/2/3) and find area of circle,rectangle and triangle.
print('MENU')
print('1.AREA OF CIRCLE')
print('2.AREA OF RECTANGLE')
print('3.AREA OF TRIANGLE')
choice=int(input('Enter choice 1/2/3:'))
if choice==1:
r=float(input('Enter radius'))
area=3.14*r*r
print('AREA OF CIRCLE=',area)
elif choice==2:
l=float(input('Enter length'))
b=float(input('Enter breadth'))
area=l*b
print('AREA OF RECTANGLE=',area)
elif choice==3:
b=float(input('Enter base'))
h=float(input('Enter height'))
area=0.5*l*b
print('AREA OF TRIANGLE=',area)
else:
print('Invalid choice!!!Please enter 1/2/3')