0% found this document useful (0 votes)
12 views9 pages

10 Practical Term1 2022 23

Uploaded by

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

10 Practical Term1 2022 23

Uploaded by

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

PROGRAMS

1. Write a program to accept temperature in Fahrenheit and convert it into centigrade .

f=float(input("accept the temperature in fahrenheit"))


print("convert the given temperature to centigrade")
c=((f-32)*5)/9
print("the temperture in centigrade is",c)

2. Write a program to find out the area and perimeter of a rectangle.

L=float(input (“accept length”))


B=float(input(“accept breadth”))
# calculating the area of the rectangle
Area=L*B
# calculating the perimeter of the rectangle
Perimeter=2*(L+B)
print(“the length is”,L)
print(“the breadth is”,B)

print(“the area of the rectangle is”,Area)


print(“the perimeter of the rectangle is”,Perimeter)

3. Write a program to accept the roll and name of the student. Find out the total and average.
Print all the details of the student.

# this is to accept marks, roll , name of the student


name=input("accept name")
roll=int(input("accept roll"))
m1=int(input("accept m1"))
m2=int(input("accept m2"))
m3=int(input("accept m3"))
# calculate total
total=m1+m2+m3
#calculate average
avg=(m1+m2+m3)/3
#avg=total/3
print("name=",name, "roll=",roll)
print("m1=",m1, "m2=",m2,"m3=",m3)
print("total=",total)
print("average=",avg)

4. write a program to accept some amount of money which was withdrawn from bank and
find out how many 2000 rupees , 1000 rupees, 500 rupees, 100 rupee, 50 rupee 20 rupee
10 rupee 5 rupee , 2 rupee and 1 rupee notes are there.-10/5/2021

amt=int(input("enter the amount withdrawn"))


d=amt//2000
amt=amt%2000
print("number of 2000 notes are",d)
print("amount left",amt)

d=amt//1000
# finding the denomination
amt=amt%1000
print("the number of 1000 rupee notes are",d)
# find the remaining amount
print("amount left after deducing 2000 and 1000 notes",amt)

d=amt//500
amt=amt%500
print("the number of 500 rupee notes are",d)
print("amount left after deducing 2000 and 1000 notes",amt)
d=amt//100
amt=amt%100
print("the number of 100 rupee notes are",d)
print("amount left after deducing 2000 and 1000 notes",amt)
d=amt//50
amt=amt%50
print("the number of 50 rupee notes are",d)
print("amount left after deducing 2000 and 1000 ,50 notes",amt)
d=amt//10
amt=amt%10
print("the number of 10 rupee notes are",d)
print("amount left after deducing 2000 and 1000 ,50,10 notes",amt)
d=amt//5
amt=amt%5
print("the number of 5 rupee notes are",d)
print("amount left after deducing 2000 and 1000 ,50,10 ,5notes",amt)
d=amt//2
amt=amt%2
print("the number of 2 rupee notes are",d)
print("amount left after deducing 2000 and 1000 ,50,10 ,5notes,2",amt)
d=amt//1
amt=amt%1
print("the number of 1 rupee notes are",d)
print(amt,sep=" ",end=" ")
print("amount left after deducing 2000 and 1000 ,50,10 ,5notes,2,1",amt)

5. Write a program to find out that accepted number is divisible both by 5 and 7. If the
accepted number is divisible both by 5 and 7 then print the message yes it is divisible
both by 5 and 7 else print not divisible

#find whether number is divisible by 5 and 7


no=int(input("accept the number"))
if no%5 ==0:
if no%7==0:
print("yes number is divisible by 5 and 7")
else:
print("number is not divisible by 5")

6. Accept three numbers and find out the biggest value.

n1=int(input("accept the first number"))


n2=int(input("accept the second number"))
n3=int(input("accept the third number"))
# finding the biggest out of three
if n1==n2 and n2==n3:
print("all numbers are carrying the same value")
elif n1>n2 and n2>n3:
print("the biggest number is",n1)
elif n2>n1 and n1>n3:
print("the biggest number is ",n2)
else:
print("the biggest number is",n3)

7. Write a program to accept the sales made by a sales person. If sales are more than 40000 the
commission is 0.3 if commission is more than 30000 and less than 40000 the commission 0.2
and if sales less than 30000 the commission is 0.1. Calculate and print the sales and
commission.

sales=int(input("enter sales:"))
# checking the sales amount
if sales>=40000:
# calculating the commission
com=(sales*0.3)/100
elif sales>=30000 and sales<40000:
com=(sales*0.2)/100
elif sales<30000:
com=(sales*0.1)/100
print("the total amount of sales",sales)
print ("the commission the sales person got",com)

8. Write a program to accept the weight of a person. If weight is more than 80 print(“over
weight ” dear child do exercise and eat healthy everyday"). If weight is greater than 60
and less than 80 print the message "your weight ok but still put some effort to reduce"
other wise print the message "normal weight, but still you need to be excercise for good
health"

# accepting weight
weight=float(input("accept the weight of a person"))
# checking the weight to print proper message
if weight>=80:
print("over weight")
print("dear child do excercise and eat healthy everyday")
elif weight<80 and weight>=60:
print("your weight ok but still put some effort to reduce")
else:
if (weight <60 and weight>=50):
print("normal weight, but still you need to be excercise for good health")
else:
print("you have to gain some weight but excercise is mandatory for maintaining
good health")

9. Write a program to accept the units consumed by the user and calculate the user’s
electricity bill . if number of units consumed are less than 100 pay only rental amount . If
number of units is greater than 100 and less than 200 calculate the bill with Rs.2 /unit
+rent deducing first 100 units. If number of units consumed is greater than 200, charge
Rs.100 for first 100 units and Rs.200/- for next 100 units and pay Rs.3/unit - for rest of units.

units=int(input("enter no of units"))
rent=100
if units<=100:
bill=rent
elif units>100 and units<=200:
bill=((units-100)*2)+rent
elif units>200:
bill=((units-200)*3)+rent+200
print (bill)

10. Write a program to accept the employee id , name and basic salary. Calculate 20 percent
da on basic salary and 15% hra on basic salary. The travelling allowance is
Rs.2000/-.Calculate the gross salary as gs=bs+da+hra+ta. Find out the annual salary. If
annual salary is greater than 10 lakhs tax is gs*0.05 and assign “HIG” to category. If gs is
less than 1000000 and greater than equal to 500000 tax to be calculated as gs*0.02 and
assign “MIG” to category other wise tax is 0 and assign LIG to category. Print all the
details of the employee.

eid=int(input("accept employee id"))


enm=input("accept name")
bs=float(input("what is the basic salary"))
da=(bs*20)//100
hra=bs*0.15
ta=2000
# calculating the gross salary
gs=bs+da+hra+ta
asal=gs*12
tax=0.0
if asal>=1000000:
tax=gs*0.05
category="HIG"
elif 1000000>asal>=500000:
tax=gs*0.02
category="MIG"
else:
tax=0.0
category="LIG"

ns=asal-tax
print("employee id=",eid, "employee name=",enm,sep=" ")
print("basic salary=",bs,"dearness allowance=",da,\
"hourse rent allowance=",hra,"travelling allowance=",ta)
print("gross salary","\t","annual salary without deduction",'\t',"tax=","\t")
print(gs,"\t",asal," \t"," ",tax)
print("net salary","\t","category")
print(ns,"\t",category)

11. Write a program to find out number of odd numbers and number of even numbers within
the range which is accepted by the user.

fn=int(input("accept the initial number"))


ln=int(input("accept the final number"))
no=ne=0
while fn<=ln:
if fn%2==0:
ne=ne+1
else:
no=no+1
fn=fn+1
print("the initial number is",fn)
print("the final number is",ln)
print("loop executed successfully")
print("number of odd numbers",no)
print("number of even numbers",ne)

12. Write a program to accept a number and find out whether it is a prime number or not.

#print("accept a number greater than 2")


no=int(input("accept a number"))
count=0

for a in range(2,no+1):
if no%a==0:
count=count+1
if count==1:
print("prime no:")
else:
print("not prime no:")

13. Write a program to print the following pattern

OUTPUT

000
001
010
011
100
101
110
111

for i in range(0,2):
for j in range(0,2):
for k in range(0,2):
print(i,j,k,sep=" ")

14. Write a program to find out the factorial of a number.

no=int(input("accept the no for which factorial you have to find :"))


fact=1
for i in range(1,no+1,1):
fact=fact*i
print("the factorial of a number",no,"is=",fact)

OUTPUT
accept the no for which factorial you have to find :5
the factorial of a number 5 is= 120

15. Write a program to accept a number and find out whether it is an automorphic number or
not.

a=int(input("accept no:"))
sq=a*a
print("The square of the number",sq)
no=a
c=0
while(a>0):
a=a//10
c=c+1
if (sq%(10**(c))==no):
print("yes autmorphic number")
else:
print("NO not autmorphic number ")

OUTPUT:-
accept no:25
The square of the number 625
yes autmorphic number

16. Write a program to print the following pattern


Q1.
11111
2222
333
44
5

Q2.
A
AB
ABC
ABCD
ABCDE
ABCDEF

for i in range(1,6,1): for i in range(65,71):


for j in range(i,6,1): for j in range(65,i+1):
print(i,end="") print(chr(j),end=" ")
print() print()
else:
print("printing the pattern")

17. Write a program to find out whether the accepted number is Armstrong number or not

n=int(input("Accept the no:"))


s=0
arm=n
while n>0:
r=n%10
s=s+(r*r*r)
n=n//10
if s==arm:

print("armstrong")
else:
print("not armstrong")

OUTPUT
Accept the no:153
armstrong
18. Write a program to accept a number and find out whether accepted number is an evil
number or not .( an evil number is a non-negative integer that has an even number of
1s in its binary expansion. ... These numbers give the positions of the zero)

no=int(input("accept the number"))


r=0
while no!=0:
if no%2==1:
r=r+1
no//=2
if r%2==0:
print("yes evil number")
else:
print("not evil number")

OUTPUT:-
accept the number8
not evil number
19. Write a program to generate the following Fibonacci series:

print("printing fibonacci series")


n=int(input("accept how many terms"))
a=0
b=1
i=1
print(a,b,sep="&",end=",")
while i<(n-1):
c=a+b
a=b
b=c
print(c,end=", ")
i=i+1

OUTPUT:-
printing fibonacci series
accept how many terms10
0&1,1, 2, 3, 5, 8, 13, 21, 34,

20. Write a program to print the sum of the values of the list

l=[10,20,30,40,50,60]

c=len(l)

sum=0

for i in range(c):

sum+=l[i]
print(sum)

OUTPUT

210

You might also like