Test Index

CBSE Class 12 Computer Science 2024 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 21 of 35
Marks: +1, -0
(A) Write a user defined function in Python named showGrades(S) which takes the dictionary S as an argument. The dictionary, S contains Name:[Eng,Math,Science] as key:value pairs. The function displays the corresponding grade obtained by the students according to the following grading rules :
Average of Eng,Math,ScienceGrade
>=90A
<90 but >=60B
<60C
For example : Consider the following dictionary
S={"AMIT":[92,86,64],"NAGMA":[65,42,43],"DAVID":[92,90,88]}
The output should be :
AMIT - B
NAGMA - C
DAVID - A
OR
(B) Write a user defined function in Python named Puzzle(W,N) which takes the argument W as an English word and N as an integer and returns the string where every Nth alphabet of the word W is replaced with an underscore ("_").
For example : if W contains the word "TELEVISION" and N is 3, then the function should return the string "TE_EV_SI_N". Likewise for the word "TELEVISION" if N is 4, then the function should return "TEL_VIS_ON".
Advertisements
Go to Question: