We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4
KENDRIYA VIDYALAYA BSF DANTIWADA-AHMEDABAD REGION
SUBJECT- COMPUTER SCIENCE
CLASS XII AUGUST MONTHLY TEST (2024-25) MAX MARKS: 40 TIME: 1 HR 30 MINS General Instructions • This paper is divided into 3 sections. • SECTION A contains 12 one marks questions. • SECTION B contains 4 three marks questions.Attempt all 4. • SECTION C contains 4 four marks questions. Attempt all 4. SECTION A 1. State True or False: 1 “In a Python program, if the denominator of a division operation is the boolean value True, then an error will be raised” 2. Select the correct output of the code: 1 a = “Induction program for PGTs” b = a.partition(“r”) print(len(b) * b[1]) a. Induction pInduction pInduction pInduction p b. rrr c. P d. TypeError 3. Consider the statements given below and then choose the correct output from 1 the given options: s1="Network devices" print(s1[3:5]+s1[:2]+s1[::5])
a. woeNrv b. worNeNrv c. woNeNrv d. woNeeki
4. State whether the following statement is True or False: 1 The finally block is executed along with the except block. 5. What will be the output of the following Python statement: 1 >>> print(4+4.00,2**4.0) a. 8.0,16.0 b. 8, 16 c. 8.0, 16 d. 8.0 16.0 6. Which of the following Python statements will perform the same operation on the 1 dictionary, “item” if item={"diary":1, "book":3, "novel":5} i. item.pop("book") ii. del item["book"] iii. item. update({"diary":1,"novel":5}) a. i, ii, iii b. i, ii c. i, iii d. ii, iii 7. What possible outputs(s) will be obtained when the following code is executed? 1 import random value=random.randrange(2,6) FRUIT=["Apple","Berry","Fig","Guava","Litchi","Papaya"] for i in range(value,len(FRUIT)): print(FRUIT[i],end=",") a. Fig, Guava, Papaya b. Guava, Litchi c. Berry, Fig, Guava, Litchi, Papaya d. Papaya 8. Which of the following statement(s) would give an error during execution of the 1 following code? L= [10, 15, 20, 25, 30] L.insert( 5, 35) #Statement 1 print(L) #Statement 2 L.extend(40) #Statement 3 L.append([45, 50]) #Statement 4 9. Given is a Python string declaration: message=‘Kendriya VidyalayaSangathan @2022-23' Write the output of: print(message[ : : -3].upper()) 10. Which of the following statements is true regarding the opening modes of a file? a. While opening a file for reading, if the file does not exist, an error occurs. b. While opening a file for writing ,if the file does not exist, an error occurs. c. While opening a file for reading, if the file does not exist, a new file is created. d. None of the above. Q 11 to 12 are ASSERTION AND REASONING based questions. Mark the correct choice as a) Both A and R are true and R is the correct explanation for A b) Both A and R are true and R is not the correct explanation for A c) A is True but R is False d) A is false but R is True 11. Assertion(A): All the sequence data types in Python, have default index values 1 starting from 0, with the exception of the dictionary which do not have default indices. Reason(R): Default Indices are only applicable for Sequence data type, whereas a dictionary is not of the Sequence data type. 12. Assertion(A): For the randint( ) function of the random module to execute 1 properly, the mandatory number of arguments is 2(lower limit, upper limit). Reason(R): When generating random number, the lower limit value is included whereas the upper limit value is excluded SECTION B 13. Predict the output of the following code: 3 L1=[1,1.33,"GFG",0,"NO",None,"G",True] val1,val2=0,"" for x in L1: if (type(x)==int or type(x)==float): val1+=x elif type(x)==str: val2+=x else: break print(val1,val2) 14. Predict the output of the following code: 3 def MODIFY(P,Q=10): P=P+Q Q=P-Q return P,Q R,S=10,15 M=MODIFY(R,S) print(M,"#",S) N=MODIFY(S) print(R,"$",N) 15. Write a function displayName(STATES) in Python, that takes the dictionary, 3 STATES as an argument and displays the capitals (in uppercase)of the states whose names end with a vowel(irrespective of its case). For example, Consider the following dictionary STATES={“Tamilnadu” : “Chennai”, “Andhra Pradesh” : “Hyderabad”, “KERALA”: “Thiruvananthapuram”} The output should be: CHENNAI THIRUVANANTHAPURAM OR Write a function, eCount(STRING), that takes a string as an argument and returns a list containing the count of the alphabet “e” in each word of a string. For example, if the string is "Regional level sport events", the list will have [1, 2, 0, 2]. 16. Predict the output of the Python code given below: 3 TXT=["400","200","700","90"] def g(C=10): CNT=3 TOTAL=0 for C in [3,5,7,9]: T=TXT[CNT] TOTAL= float(T)+C print(TOTAL) CNT-=1 return CNT print(g(3)) SECTION C 17. Write a function in Python to read a text file, Book.txt and display those lines 4 which have more than 5 words in it. OR Write a function in Python to read a text file, Book.txt and display those lines which have at least one number in it. 18. a) Explain underflow condition in stack with the help of python code. 4 b) Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all numbers divisible by 5 into a stack. Display the stack if it has at least one element, otherwise display appropriate error message. OR i) Write some applications of stack. ii) Write a function in Python popStack(st), where st is a stack implemented by a list of numbers. The function returns the value deleted from the stack 19. Krishna is a Python programmer working in a school. For the Annual School 4 Magazine, he has created a csv file named Magazine.csv, to store the number of articles collected from students in different categories. The structure of Magazine.csv is : [Adm_no, St_Name, Article, Category] Where Adm_no is Admission number (integer) St_Name is Student Name (string) Article is name of the article which the student is submitting(string) Category is the category of the student submitting the article whose value can be either 'Junior', 'Senior' or 'Super Senior' For efficiently maintaining data of the event, Krishna wants to write the following user defined functions: Accept() – to accept a record from the user and add it to the file Magazine.csv. The column headings should also be added on top of the csv file. categoryCount() – to count the number of students who have submitted the articles in each category. As a Python expert, help him complete the task. Example: Magazine.csv contains: ['Adm_no', 'St_Name', 'Article', 'Category'] ['1101', 'radha', 'AI AND ITS IMPACT', 'Junior'] ['102', ‘Kumar’, 'CYBER SECURITY', 'Senior'] ['103', 'raman', 'Career Planning', 'Junior'] ['104', 'megha', 'Data Science', 'Super Senior'] The output should be {'Junior': 2, 'Senior': 1, 'Super Senior': 1} 20. (i) What exception occurs when trying to open a non-existing file in read 4 mode? (ii) Consider a file, WEATHER.DAT, containing records of the following structure: [CityName, Max_temp, Min_temp] Write a function, copyData(), that reads contents from the file WEATHER.DAT and copies all the records with Maximum temperature lesser than 80℉ to the file COLDER.DAT. The function should return the name of the City with the lowest temperature copied to COLDER.DAT. For example : WEATHER.DAT contains: ['CityName', 'Max_temp', 'Min_temp'] ['Chennai', 92, 82] ['Banaskantha', 86, 76] ['Jammu', 91, 78] ['Srinagar', 70, 62]
Practical Rust Projects: Build Serverless, AI, Machine Learning, Embedded, Game, and Web Applications (2nd ed.) 2nd Edition Shing Lyu - Download the full set of chapters carefully compiled