Practical 2
Practical 2
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
print("Maximum of English Marks:",maxE)
print("Average of English Marks:",sumE/leng)
print("Minimum of Mathematics Marks:",minM)
print("Maximum of Mathematics Marks:",maxM)
print("Average of Mathematics Marks:",sumM/leng)
print("Minimum of Total Marks:",minT)
print("Maximum of Total Marks:",maxT)
print("Average of Total Marks:",sumT/leng)
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
SumE=0
for i in L:
if i%2==0:
SumE+=i
def AddOdd(L):
SumO=0
for i in L:
if i%2!=0:
SumO+=i
def AddZeroEnd(L):
SumZE=0
for i in L:
d=i%10
if d == 0:
SumZE+=i
def Show7Ten(L):
for i in L:
d=(i//10)%10
if d==7:
print(i)
def Show20_50(L):
for i in L:
if i >20 and i<50:
print(i)
L=[]
L=AddValues(L)
DispValues(L)
RevContent(L)
DispValues(L)
AddEven(L)
AddOdd(L)
AddZeroEnd(L)
Show7Ten(L)
Show20_50(L)
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
choice=input("More(y/n)?")
if choice in "nN":
break
return L
def DispValues(L):
for i in L:
print(i)
def SwapPair(L):
for i in range(0,len(L),2):
L[i],L[i+1]=L[i+1],L[i]
def SwapHalf(L):
hv=len(L)//2
L[:hv:],L[hv::]=L[hv::],L[:hv:]
L=[]
L=AddValues(L)
DispValues(L)
SwapPair(L)
DispValues(L)
SwapHalf(L)
DispValues(L)
def AllUCase(C):
l=len(C)
for i in range(0,l,1):
C[i]=C[i].upper()
def ShowDisplay(C):
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
print(C)
def Arrange(C):
C=sorted(C,reverse=True)
print(C)
def ShortNameCities(C):
ShortCity=[]
for i in C:
if len(i)<=4:
ShortCity.append(i)
print(ShortCity)
def BigNameCities(C):
BigCity=[]
for i in C:
if len(i)>4:
BigCity.append(i)
print(BigCity)
def CityNameLength(C):
Length=[]
for i in C:
LEN=len(i)
Length.append(LEN)
print(Length)
L=[]
L=AddCity(L)
ShowDisplay(L)
AllUCase(L)
ShowDisplay(L)
Arrange(L)
ShowDisplay(L)
ShortNameCities(L)
BigNameCities(L)
CityNameLength(L)
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
B.append(book)
opt=input("more Y/N?")
if opt in "Nn":
break
return B
def AllIndia(B):
b=B
for i in range(0,len(b)):
b[i]=b[i].lower()
if "india" in b[i]:
print(B[i])
def ShowBooks(B):
print(B)
def SingleWords(B):
for i in B:
S=i
c=1
S.strip()
for i in range(0,len(S)):
if S[i]==" ":
c+=1
if c==1:
print(S.upper())
def CountSingle(B):
count=0
for i in B:
S=i
c=1
S.strip()
for i in range(0,len(S)):
if S[i]==" ":
c+=1
if c==1:
count+=1
print(count)
def ThetoA(B):
for i in range(0,len(B)):
S=B[i]
S=S.title()
S=S.replace("The","A")
B[i]=S
print(B)
B=[]
B=AddBooks(B)
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
ShowBooks(B)
AllIndia(B)
SingleWords(B)
CountSingle(B)
ThetoA(B)
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
print(W)
MyDays={}
OfficeDays={}
MyDays[2]="TUE"
MyDays[4]="THU"
MyDays[7]="SUN"
del W[2]
del W[4]
del W[7]
OfficeDays=W
print(MyDays,OfficeDays)
General Instructions:
i. Type the solution of all the problems using Python Language on Python IDLE or Colab
ii. Type the following on top of each of your program as comment lines
"""
Program List : <Practical Assignment List number appears here>
Program No : <Question number in the list>
Developed By : <Your name appears here>
Date : <Date when the program was coded appears here>
"""
iii. On successful execution with meaningful data, copy and paste the sample meaningful output at the bottom of the
[REF:DPSR/COMP12/2023-2024/L2]
Delhi Public School, R.K.Puram, New Delhi
program as comment lines.
iv. Add all the codes in separate pages of a single Google Doc named as in the format as
<Class>-<Section>-<L2>-<Name> For example XII-F-L2-Jai Mathir (If the Name is Jai Mathir of XII-F)
NOTE: Recommended Font, “Courier New”, Style “Bold” Size “10” for all programs with single line
spacing. Default indentation 2 Character only.
v. “Turn in” the Doc as a single document in response to this assignment submission with all programs. Once
verified by the teacher, take out a hardcopy from the printer and get them signed by the respective computer
teacher.
[REF:DPSR/COMP12/2023-2024/L2]