Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore NBSE Question Papers Computer Science Term-1 (Set-2) for Class 12

NBSE Question Papers Computer Science Term-1 (Set-2) for Class 12

Published by Full Marks Pvt Ltd, 2021-11-16 06:29:34

Description: NBSE Question Papers Computer Science Term-1 (Set-2) for Class 12

Keywords: NBSE Question Papers Computer Science Term-1 (Set-2) for Class 12

Search

Read the Text Version

Class 12  SET-2 Series NBSE/XII/2021 TERM-I Code No. 083/12/2 Roll No.  Candidates must write the Code No. on the title page of the OMR sheet. l Please check that this question paper contains 8 pages. l Code number given on the right hand side of the question paper should be written on the title page of the OMR sheet. l Please check that this question paper contains 55 questions. l 15 minutes time has been allotted to read this question paper. COMPUTER SCIENCE Time Allowed : 90 Minutes Maximum Marks : 35 General Instructions: 1. The question paper is divided into 3 Sections - A, B, and C. 2. Section A consists of 25 Questions (1-25). Attempt any 20 questions. 3. Section B consists of 24 Questions (26-49). Attempt any 20 questions. 4. Section C consists of 6 case study based Questions (50-55). Attempt any 5 questions. 5. All questions carry equal marks. NBSE 2021 1 [P.T.O.

SECTION-A This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this section. Choose the best possible option. 1. Which of the following is valid arithmetic operator in Python? (a) // (b) ? (c) < (d) and 2. Which of the following is an invalid variable? (a) my_string_1 (b) 1st_string (c) foo (d) _ 3. What keyword would you use to add an alternative condition to an if statement? (a) else if (b) elseif (c) elif (d) None of these 4. Which statement will check if a is equal to b? (a) if a = b: (b) if a = = b: (c) if a = = = c: (d) if a = = b 5. Which type of error occurs when rules of programming language are misused? (a) Syntax error (b) Semantic error (c) Run time error (d) Logical error 6. Text files store information in ……. Characters. (a) ASCII (b) Unicode (c) Both (a) and (b) (d) None of these 7. Sorting means arranging the elements in (a) Ascending order (b) Descending order (c) Either (a) or (b) (d) None of these 8. To read two bytes from a file object infile, we use (a) infile.read(2) (b) infile.read() (c) infile.readline() (d) infile.readlines() 9. Which of the following symbol is used in Python for Multiline comments line comment? (a) /*** (b) /* (c) ''' (d) # 10. When one or more elements of a list is another list, it is called (a) nested list (b) super list (c) hit list (d) sub list 11. Which method is used to delete a given element from the list? (a) rem() (b) remove() (c) del() (d) delete() 12. Which method is used to return count of tuple elements? (a) len(t) (b) count(t) (c) Total(T) (d) Sum(T) 13. Which type of brackets is used to define the tuple? (a) [] (b) () (c) {} (d) <> 14. The unordered and changeable collection of data values that holds key value pairs is (a) List (b) Tuple (c) Dictionary (d) String 15. Identify the elements that are classified by Python dictionary. (a) Keys (b) Values (c) Both (a) and (b) (d) None of these 16. ………….. is a file containing Python definitions and statements. (a) Module (b) List (c) Tuple (d) Dictionary 17. Which keyword is used to import the module ……? (a) Import module (b) Module (c) Import (d) None of these NBSE 2021 2

18. What are the two main types of functions? (i) Custom function (ii) Built in function (iii) User define function (iv) System function (a) (i) and (ii) (b) (ii) and (iii) (c) (iii) and (iv) (d) (i) and (iv) 19. What will be the output of the following code? print(type(type(int))) (a) type 'int' (b) <class 'type'> (c) Error (d) <class 'int'> 20. Which of the following is the use of id() function in python? (a) id() returns the identity of the object (b) Every object doesn't have a unique ID (c) All of the mentioned (d) None of the mentioned 21. Which of the following refers to mathematical function? (a) sqrt (b) Rhombus (c) add (d) Sqrt add 22. Which of these is/are formal argument(s)? (a) Required argument (b) Keyword argument (c) Default argument (d) All of these 23. Parameters are defined inside (a) Angular brackets (b) Square brackets (c) Mid brackets (d) Parentheses 24. To read the entire remaining contents of the file as a string from a file object infile, we use…. (a) infile.read(2) (b) infile.read() (c) inflie.readline() (d) infile.readlines() 25. It determines the mode in which the file has to be opened. It is (a) file name (b) access_mode (c) dump (d) pickle SECTION B This section consists of 24 Questions (26 to 49). Attempt any 20 questions. 26. What will be output of this expression 'p' + 'q' (a) pq (b) rs (c) pqrs (d) pq12 27. Which of the following is valid for loop in Python? (a) for(i=0;i<n;i++) (b) for i in range(0,5): (c) for i in range(0,5) (d) for i in range(5) 28. What will be the output of the following code? x = 12 for i in x: print(i) (a) 12 (b) 1 2 (c) Error (d) None of these NBSE 2021 3 [P.T.O.

29. What will be the output of the following code? x= \"abcdef\" i= \"i\" while i in x: print (i, end= \" \") (a) a b c d e f (b) abcdef (c) i i i i i … (d) No output 30. What type of elements are accepted by random.shuffle()? (a) Tuples (b) Dictionaries (c) Lists (d) Strings 31. Suppose a tuple T is declared as T=(10,12,43,39), which of the following is incorrect? (a) print(T[1]) (b) T[2]= -29 (c) print(max(T)) (d) print(len(T)) 32. What is the output when the following code is executed? print(r\"\\nhello\") (b) \\nhello (a) a new line and hello (c) The letter r and then hello (d) Error 33. Consider the following code and answer the question that follows: Book={1:'Thriller',2:'Mystery',3:'Crime',4:'Children Stories'} Library={'5':'Madras Diaries', '6':'Malgudi Days'} Ramesh needs to change the title in the dictionary book from 'Crime' to 'Crime thriller'. He has written the following command: Book['Crime']='Crime Thriller' But he is not getting the answer. Help him choose the correct command: (a) Book[2]='Crime Thriller' (b) Book[3]='Crime Thriller' (c) Book[2]=('Crime Thriller') (d) Book[3]=('Crime Thriller') 34. What will be the output of the following code? L=['a','b','c','d'] print\" \".join(L) (a) Error (b) a b c d (c) ['a','b','c','d'] (d) None 35. What will be the output of the following python code? def cube(x): return x*x*x x=cube(2) print(x) (a) 2 (b) 4 (c) 8 (d) 20 36. Here is the function to find the sum of arguments total = 0 #Line1 def sum(arg1, arg2): #Line2 NBSE 2021 4

total = arg1 + arg2 #Line3 print (\"total:\", total) #Line4 return total #Line5 sum (10, 20) #Line6 print (\"…… : \", total) #Line7 Fill the blank in line 7 (a) Sum (b) True (c) False (d) Total 37. To open a file c:\\scores.txt for reading, we use …….. (a) infile=open(\"c:\\scores.txt\",\"r\") (b) infile=open(\"c:\\\\scores.txt\",\"r\") (c) infile=open(file=\"c:\\scores.txt\",\"r\") (d) infile=open(file=\"c:\\\\scores.txt\",\"r\") 38. What will be the output of the following Python code? f=None for i in range (5): with open(\"data.txt\",\"w\") as f: if i > 2: break print(f.closed) (a) true (b) false (c) None (d) Error 39. What will the following code produce? T=['kvs','rpr'] T1=range (len(T)) for i in T1: T[i]=T[i].upper() print(T) (a) ['KVS','RPR'] (b) ['kvs','rpr'] (c) ['Kvs','Rpr'] (d) Error 40. Consider square numbers defined as follows: compute(1) = 1 compute(N) = computer(N-1) + 2N-1 According to this definition, what is compute (3)? (a) compute(3) = compute(2) +compute(1) (b) compute(3) = compute(2) + 2*3-1 (c) compute(3) = compute(2) -2'3+1 (d) compute(3) = compute(3) +2*3-1 41. What will be the output of the following python code? a=10 def call(): global a a=15 b=20 NBSE 2021 5 [P.T.O.

print(a) (b) 35 (c) 15 (d) 10 call() (a) 25 42. Suppose content of 'Myfile.txt' is: Twinkle twinkle little star How I wonder what you are Up above the world so high Like a diamond in the sky What will be the output of the following code? myfile = open(\"Myfile.txt\") data = myfile.readlines() print(len(data) myfile.close() (a) 3 (b) 4 (c) 5 (d) 6 43. Choose the correct option with reference to below Python code? def fn(a): (b) a is the actual argument. print(a) x=90 fn(x) (a) x is the formal argument. (c) fn(x) is the function signature. (d) x is the actual argument. 44. What is the output of the following? d = (\"one\": 'I', \"two\" : 'II', \"three\" :'III'} for i in d: print(i) (a) one (b) I (c) one I (d) 0 two II two II 1 three III three III 45. What is the output of the program given below? num = 45 def func (num): num = 23 func (num) print ('num is now', num) (a) num is now 45 (b) num is now 23 (c) num is now 68 (d) Error NBSE 2021 6

46. Find the output of the following >>> list1=[1,2,3] >>> list2=[1,2,2,3] >>> list1>list2 (a) Error (b) False (c) True (d) None 47. Consider the following code: import math import random print(str(int(math.pow(random.randint(2,4),2))),end= ' ') print(str(int(math.pow(random.randint(3,4),2),end= ' ') print(str(int(math.pow(random.randint(4,4),2)))) What could be the possible outputs of the given four choices? (a) 2 3 4 (b) 9 16 16 (c) 16 4 16 (d) 2 4 9 (d) Error 48. Consider the tuple in python named NUM=(1,2,3). What will be the value of DOUBLE, if - >>> DOUBLE=NUM*2 (a) (2,4,6) (b) (1,1,2,2,3,3) (c) (1,2,3,1,2,3) 49. Consider the following program. What is the correct flow of execution of statements: 1 def fun1(m,n): 2 c=m+n 3 print (c) 4 return c 5 x=10 6 y=20 7 fun1(x,y) 8 print(\"OK\") (b) 5,6,7,1,2,3,4,8 (a) 1,2,3,4,5,6,7,8 (c) 5,6,1,2,3,4,7,8 (d) 7,8,1,2,3,4,5,6 SECTION-C (CASE STUDY) This section consists of 6 Questions (50 -55). Attempt any 5 questions. A binary file \"Book.DAT\" has structure [Bookno, Book_Name, Author, Price]. Ravi, a student of class 12 Computer Science is told to create the file and search for the number of books of a specific author by completing the blank lines. import pickle def create File(): NBSE 2021 7 [P.T.O.

fobj=_______________ #Line1 to open file for entering data to file BookNo=int(input(\"Book Number : \")) Book_name=input(\"Name :\") Author = input(\"Author: \") Price = int(input(\"Price : \")) rec=[BookNo,Book_Name,Author,Price] _________________ #Line2 to store data to file fobj.close() def Count Rec(Author): fobj=_______________ #Line3 to open file for searching num= 0 try: while True: rec=_____________ # Line4 to read a record if Author=______: #Line5 to check for specific author num = num + 1 except: fobj.close() return num 50. Fill in the blank in Line1, to open the file \"Books.DAT\" for writing in binary format? (a) open(\"Book.dat\",\"ab\") (b) open(\"Books.DAT\",'wb') (c) open(\"Books.DAT\",'a') (d) open(\"Books.DAT\",'w+') 51. Fill in the blank in Line2, to write the list rec into the binary file, Books.DAT? (a) pickle.write(re(c) (b) pickle.dump(rec,fobj) (c) pickle.dump(fobj,re(c) (d) fobj=pickle.dump(re(c) 52. Fill in the blank in Line3, to open the file \"Books.DAT\" for searching. (a) open(\"Book.dat\",\"r\") (b) open(\"Book.dat\",\"rb\") (c) open(\"Book.dat\",\"wb\") (d) open(\"Book.dat\",\"ab\") 53. Fill in the blank in Line4, to read record from file. (a) pickle.read(f) (b) pickle.load(f) (c) pickle.load(fobj) (d) pickle.read(fobj) 54. Fill in the blank in Line5 with suitable expression: (a) rec[0] (b) rec[1] (c) rec[2] (d) rec[3] 55. CSV stands for (a) Comma Separated Values (b) Comma Single Version (c) Common Seprated Values (d) Common Single Version NBSE 2021 8


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook