Class 11 Prac Programs 2022
Class 11 Prac Programs 2022
Class 11 Prac Programs 2022
n=int(input("enter number"))
print(n*1,n*2,n*3,n*4,n*5)
2. Program to convert rupee to dollar and dollar to rupee using menu driven format . (1
dollar=80rs)
choice=int(input ("enter the choice 1 or 2"))
if (choice==1):
rs=int(input("Enter the amt in rupees"))
dollar=rs/80
print("The dollar value is ",dollar)
else:
dollar=int(input("Enter the amount in dollars"))
rs=dollar*80
print("The rupees value is ",rs)
if (year%100!=0):
if (year%4==0):
print("leap year")
elif year%400==0:
print("millennium leap year")
else:
print("not leap year")'''
4. Finding sum of all positive numbers,As soon as a negative number is inputted break
happens.while(True ) is always true (that is it can never be false ), loop goes on .
the only way to stop is through the break statement.
entry=0
sum=0
print("enter positive numbers ,negative numbers will end the list")
while(True):
entry=int(input("enter number")) #entry=eval(input())
if (entry<0):
break
sum=sum+entry
print(sum)
6. Write program using while loop for summation of first 10 natural numbers.
j=1
s=0
while(j<11):
s=s+j
j=j+1
print("The added result is",s)
9. Write program to read two numbers and an arithmetic operator and display
#the computed result.
choice='yes'
while(choice=='yes'): #True
num1=int(input("Enter the number1"))
num2=int(input("Enter the second number"))
op=input("Enter the operator")
if op=='+':
result=num1+num2
print(result)
elif (op=='-'):
result=num1-num2
print(result)
elif(op=='*'):
result=num1*num2
print(result)
choice=input("Do you want to continue?") #y
10. Write a python program to Calculate GST%.
Originalprice = 100
Netprice = 124.7
GSTamount = Netprice - Originalprice
GSTpercent = ((GSTamount * 100) / Originalprice)
print("GST = ",end='')
print(round(GSTpercent),end='')
print("%")
11. Write a program to display consonants alternating with a '*' symbolin the string "amazing".
str="amazing"
str1=""
for i in str:
if i not in ('aeiou'):
print(i,end="*")
12. Write a program to find the position of a value if present in a list otherwise insert the value at a
particular position in the list.
list1=[23,45,12,29,45,15]
c=0
x=int(input("enter the value "))
if x not in list1:
pos=int(input("enter the position"))
list1.insert(pos,x)
elif x in list1:
y=list1.index(x)
c=list1.count(x)
print(list1," ",c," ",x," ",y)
13. Write a program to use options from the user and perform few builtin functions.
list1=[12,34,13,15,"hello"]
opt=0
continu='y'
while(continu=='y'):
opt=eval(input("enter the options"))
if opt==1:
x=int(input("enter the appending value"))
list1.append(x)
print(list1)
elif opt==2:
y=eval(input("enter the extending values"))
list1.extend(y)
print(list1)
elif opt==3:
p=1
list1.pop(p)
print(list1)
continu=input("do u want to continue")
14. Write a program to convert strings in the list into the opposite case and if it is integer square the
item in the list.
List=['hello',45,'welcome','AFTER']
l=len(list1)
for i in range(0,l):
if type(list1[i])==str:
list1[i]=list1[i].swapcase()
elif type(list1[i])==int:
list1[i]=list1[i]**2
print(list1)
15. Write a program such that If the occurrence of an item is more than once then remove that item.
list1=[12,14,16,12,10,22,16]
for i in list1:
x=list1.count(i)
if x>1:
list1.remove(i)
print(list1)
16. Let there be a parent list .list1=[5,1,9,10,11,3]
Let there be a variable threshold.If items are less than the threshold value then wap to put 0 otherwise
put 1 at that location in the list.
list1=[5,1,9,10,11,3] #parent list
threshold=int(input("enter the threshold value ")) #5
list2=[0]
l=len(list1) #6
for i in range(0,l):
if list1[i]<=threshold:
list2.append(0)
else:
list2.append(1)
print(list2)
17. Wap to read a list and divide by 10 if the numbers are even.
L=[12,17,19,22,23]
length=len(L)
for i in range (0,length):
if L[i]%2==0:
L[i]=L[i]/10
print(L)
18. Wap to append 3 fruit names and do the functions on it.
1)reverse
2)insert
3)Find a fruit and its location.
list=[]
proceed="yes"
for i in range(0,2):
fruitnames=input("enter the fruit")
list.append(fruitnames)
print(list)
while (proceed=="yes"):
ch=int(input("enter thechoice"))
if ch==1:
print(list)
list.sort(reverse=True)
print(list)
elif ch==2:
x=input("enter the fruit to insert")
location=int(input("enter the location"))
list.insert(location,x)
print(list)
elif ch==3:
x=input("enter the fruit to search ")
for i in range (len(list)):
if x==list[i]:
#count=count+1
print(x,"is present at location",i+1)
proceed=input("do you want to continue")
19. #Create a dictionary stud interactively.with value marks and rollnum.
stud={}
n=int(input("enter the number of students"))
for i in range(0,n):
name=input("enter the name of the student")
marks=int(input("enter the marks"))
roll=int(input("enter the rollnum"))
stud[name]=[marks,roll]
print(stud)
k=stud.keys()
for i in k:
print(i)
v=stud[i]
for j in v:
print(j)
20. Wap to find the number of occurences of each letter in the parent string. and show the output in a
dictionary as key and values where key will be the letter and number of occurrences will be the value.
str="hello python"
dicta={}
for key in str:
if key in dicta:
dicta[key]=dicta[key]+1
else:
dicta[key]=1
for key in dicta:
print(key," ",dicta[key])
21.
Case study. Wap to display,insert,delete,modify,to check,to sort the values in the dictionary dicta.
num=int(input("Enter the number of students"))
dicta={}
for i in range(0,num):
name=input("Enter friends name")
phone=int(input("enter the phone number"))
dicta[name]=phone #value
i=i+1
print(dicta)
k=dicta.keys()
opt=int(input("enter the option to display the dictionary"))
if opt==1:
print(dicta)
elif opt==2:
name=input("Enter a new friends name ")
phone=int(input("enter new friends phone number"))
dicta[name]=phone
print(dicta)
elif opt==3:
name=input("enter the name of the friend to be deleted")
if name in dicta:
del dicta[name]
print(dicta)
elif opt==4:
name=input("enter the name of the friend to be modified")
phone=int(input("enter the phone number to be modified...."))
dicta[name]=phone
print(dicta)
elif opt==5:
x=input("enter the name of the friend to be checked...")
for i in k:
if i==x:
print("Friend is present",i," ",dicta[i])
elif opt==6:
s=sorted(dicta.items())
print(s)
25. Write a program to enter the price and quantity of an item purchased by the customer and to
compute and print the total amount ,discount amount and net amount to be paid by the customer. The
following is the criteria for giving discounts on the items purchased.
If total amount is between 0 and 25000 then the discount of 5% given
If the total amount is between 25001 and 50000 then a discount of 10% is given
If the total amount payable is above 50000 then the discount is 20%.
26. Write a program that accepts the Basic Pay of an employee and calculates DA as 70% of Basic
and HRA as 25% of Basic. The program should print the basic Pay,DA,HRA and total Pay. Total Pay is
calculated as Basic + DA + HRA.
27.Write a program for calculating the total amount to be paid by a client for hiring cab for his business
trip. Service tax of 9% of total amount payable.
Per day charges for cab is as follows: