Sample Program File Class 11
Sample Program File Class 11
PROGRAM FILE
NAME:
CLASS:
SECTION:
INDEX
Q1 #WAP Take two integer values from user and print greatest among them.
if(no1>no2):
elif(no2>no1):
elif(no1==no2):
else:
'''
output
enter no1: 3
enter no2: 4
'''
Q2 A school has following rules for grading system:
a. Below 25 - F
b. 25 to 45 - E
c. 45 to 50 - D
d. 50 to 60 - C
e. 60 to 80 - B
f. Above 80 - A
sol
m=int(input("enter marks"))
if(m<25):
elif(m>=80): #else:
#-----------------OR-----------------
m=int(input("enter marks"))
if(m<25):
elif(m<45):
print(" Grade E")
elif(m<50):
elif(m<60):
elif(m<80):
elif(m>=80): #else:
‘’’
Output
enter marks76
Grade B
‘’’
Q3
A company decided to give hra,da according to the foolowing criteria if his/her year of service is
no of years hra da
Ask user for their salary and year of service and print the net salary.
SOL
n=eval(input("enter salary"))
y=int(input("enter no of years"))
h=n*0.05
d=n*0.03
#print("net salary",n+h+d)
h=n*0.04
d=n*0.02
#print("net salary",n+h+d)
else: #elif(y>=20):
h=n*0.06
d=n*0.07
#print("net salary",n+h+d)
'''
output
enter salary3450
enter no of years6
'''
Q4 #Program that demonstrate the use of Nested if- if within another if
Sol:
a=int(input("enter age"))
if(a<15):
else:
else:
'''
output
enter age8
age is between 0 to 10
'''
Q5
sol
for i in range(1,11):
print(i)
'''
Output
10
‘’’
Q6
'''
'''
sol
n=int(input("enter no"))
s=0
for i in range(1,n+1):
s=s+i
'''
output
enter no6
'''
Q7
'''
'''
sol
n=int(input("enter no"))
for i in range(1,11):
print(n,"x",i,"=",n*i)
'''
output
enter no8
8x1=8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40
8 x 6 = 48
8 x 7 = 56
8 x 8 = 64
8 x 9 = 72
8 x 10 = 80
'''
Q8 # Concept of nested loop
Ans
#--------------------------------------
for i in range(4,0,-1):
for j in range(5,i,-1):
print(i,end="")
print()
'''
33
222
1111
'''
for i in range(4):
for j in range(i+1):
print("*",end="")
print()
'''
**
***
****
'''
Q9
sol
s=input("enter string")
c=0
for i in s:
if (i.isupper()):
c=c+1
print(c)
'''
output
‘’’
Q10
sol
s=input("enter string")
c=0
for i in s:
if i in "aeiouAEIOU":
c=c+1
print(c)
'''
output
'''
Q11
# Program to display those words which are ending with capital alphabets
s=input("enter string")
c=0
for i in s.split():
if i[-1].isupper():
c=c+1
print(c)
'''
output
'''
Q12
#Program to convert uppercase into lowercase and vice versa and not to use built in functions
for i in S:
print(chr(ord(i)+32),end="")
print(chr(ord(i)-32),end="")
'''
output
tHIsisMyfiLE
'''
Q12
#Program to capitalize first and last letters of each word of a given string
Sol
s=input("enter string")
r=" "
s=s.title()
for i in s.split():
r=r+i[:-1]+i[-1].upper()+" "
print(r)
'''
output
ThiS IS MY FilE
'''
Q13
'''
'''
Sol
a=[2,56,78,98,90,50,45,67]
for i in a:
if(i%5==0):
i=5
print(i,end=" ")
else:
i=0
print(i,end=" ")
'''
output
00005550
'''
#OR
a=[2,56,78,98,90,50,45,67]
for i in range(len(a)):
if(a[i]%5==0):
a[i]=5
else:
a[i]=0
print(a)
'''
output
[0, 0, 0, 0, 5, 5, 5, 0]
'''
Q14'''
'''
Sol
a=[2,56,78,98,90,50,45,67]
for i in a:
if(i%7==0):
i=i//7
print(i,end=" ")
else:
i=i*3
print(i,end=" ")
'''
output
'''
#OR
a=[2,56,78,98,90,50,45,67]
for i in range(len(a)):
if(a[i]%7==0):
a[i]=a[i]/7
else:
a[i]=a[i]*3
print(a)
'''
output
'''
Q15
'''
'''
a=[2,56,78,98,90,50,45,67]
for i in a:
if(i%2==0):
i=i+10
print(i,end=" ")
else:
i=i+5
print(i,end=" ")
'''
output
12 66 88 108 100 60 50 72
'''
Q16
'''
'''
c=0
d=0
for a in range(a,b+1):
for i in range(2,a):
if(a%i==0):
c=c+1
break
else:
d=d+1
print("total prime",d)
'''
output
total prime 6
'''
Q17
‘’’
WAP that creates a third tuple after adding two tuples. Add second after first tuple.
‘’’
a=(1,2,3)
b=(4,5,6)
c=a+b
print(c)
‘’’
Output
(1,2,3,4,5,6)
‘’’
Q18
‘’’
‘’’
t=eval(input("enter tuple"))
l=len(t)
a=0
s=0
for i in range(0,l):
s=s+t[i]
a=s/l
'''
output
enter tuple1,2,3,4
'''
Q19
'''
WAP to store book id, book name and price of three books and store the data in dictionary name "dict"
'''
dict={}
for i in range(3):
dict[b_id]=b_name,b_price
print(dict)
'''
OUTPUT
{1: ('abc', 450), 2: ('cs with python', 279), 3: ('cs with c++', 350)}
'''
Q20
‘’’
‘’’
a=0
while a!=1:
print("6. exit")
d={}
if(ch==1):
for i in range(n):
r=input("enter rollno")
n=input("enter name")
m=int(input("enter marks"))
d[r]=n,m
print(d)
elif(ch==2):
for i in d:
print(i,d[i])
elif(ch==3):
for i in d:
if(i==s):
print(d[i])
elif(ch==4):
for i in d:
if(i==s):
d.pop(s)
print(d)
elif(ch==5):
d[s]=v
print(d)
elif(ch==6):
a=1
‘’’
output
1. add information
6. exit
enter rollno1
enter namereena
enter marks70
enter rollno2
enter nameteena
enter marks80
enter rollno3
enter namesheena
enter marks89
1. add information
6. exit
('reena', 70)
1. add information
6. exit
enter namemeena
enter marks97
after modification dictionary is {'1': ('reena', 70), '2': ('teena', 80), '3': ('meena', 97)}
1. add information
6. exit
1. add information
6. exit
‘’’
Q20
‘’’