uk
Feedback
CBSE COMPUTER SCIENCE

CBSE COMPUTER SCIENCE

Відкрити в Telegram

QUESTION BANK, REFERENCE BOOK, LAB MANUAL , WORKSHEET ETC., PYTHON TEXT BOOK AND REFERENCE BOOKS, 01. ASK QUESTIONS AT https://t.me/joinchat/FJ1noGs-64I0OWI1

Показати більше
549
Підписники
Немає даних24 години
Немає даних7 днів
Немає даних30 день
Архів дописів
What is the output of the following code? def change(i = 1, j = 2): i = i + j j = j + 1 print(i, j) change(j = 1, i = 2) a)An exception is thrown because of conflicting values b)1 2 c)3 3 d)3 2 Answer: d What is the output of the following code? def display(b, n): while n > 0: print(b,end="") n=n-1 display('z',3) a)zzz b)zz c)An exception is executed d)Infinite loop Answer: a What is the output of the following code? def foo(i, x=[]): x.append(i) return x for i in range(3): print(foo(i)) a) [0] [1] [2] b) [0] [0, 1] [0, 1, 2]. c) [1] [2] [3]. d) [1] [1, 2] [1, 2, 3]. Answer: b What is the output of the following code? def foo(k): k = [1] q = [0] foo(q) print(q) a) [0]. b) [1]. c) [1, 0]. d) [0, 1]. Answer: a What is the output of the following code? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q)) a) True b) False c) None d) Error Answer: a What is the output of the following? def foo(i, x=[]): x.append(x.append(i)) return x for i in range(3): y = foo(i) print(y) a) [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]. b) [[0], [[0], 1], [[0], [[0], 1], 2]]. c) [0, None, 1, None, 2, None]. d) [[[0]], [[[0]], [1]], [[[0]], [[[0]], [1]], [2]]]. Answer: c The output of the code shown below is: def f1(): x=15 print(x) x=12 f1() a) Error b) 12 c) 15 d) 1512 Answer: c What is the output of the code shown? def f1(): global x x+=1 print(x) x=12 print("x") a) Error b) 13 c) 13 d) x Answer: d What is the output of the code shown below? def f1(): x=100 print(x) x=+1 f1() a) Error b) 100 c) 101 d) 99 Answer: b What is the output of the following code? x=12 def f1(a,b=x): print(a,b) x=15 f1(4) a) Error b) 12 4 c) 4 12 d) 4 15 Answer: c What is the output of the code shown below? def f(x): print("outer") def f1(a): print("inner") print(a,x) f(3) f1(1) a) outer and error b) inner and error c) outer and inner d) error Answer: a What is the output of the code shown? def f(): global a print(a) a = "hello" print(a) a = "world" f() print(a) a) hello and hello and world b) world and world and hello c) hello and world andworld d) world and hello and world Answer: b

PYTHON : OUTPUT FINDING PROGRAMS-FUNCTIONS What is the output of the below program? def sayHello(): print('Hello World!') sayHello() sayHello() a) Hello World! and Hello World! b) ‘Hello World!’ and ‘Hello World!’ c) Hello and Hello d) None of the mentioned Answer: a What is the output of the below program? def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4) a) 3 b) 4 c) 4 is maximum d) None of the mentioned Answer: c What is the output of the below program ? x = 50 def func(x): print('x is', x) x = 2 print('Changed local x to', x) func(x) print('x is now', x) a) x is now 50 b) x is now 2 c) x is now 100 d) None of the mentioned Answer: a What is the output of the below program? x = 50 def func(): global x print('x is', x) x = 2 print('Changed global x to', x) func() print('Value of x is', x) a) x is 50 Changed global x to 2 Value of x is 50 b) x is 50 Changed global x to 2 Value of x is 2 c) x is 50 Changed global x to 50 Value of x is 50 d) None of the mentioned Answer: b What is the output of below program? def say(message, times = 1): print(message * times) say('Hello') say('World', 5) a) Hello and WorldWorldWorldWorldWorld b) Hello and World 5 c) Hello and World,World,World,World,World d) Hello and HelloHelloHelloHelloHello Answer: a What is the output of the below program? def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(3, 7) func(25, c = 24) func(c = 50, a = 100) a) a is 7 and b is 3 and c is 10 a is 25 and b is 5 and c is 24 a is 5 and b is 100 and c is 50 b) a is 3 and b is 7 and c is 10 a is 5 and b is 25 and c is 24 a is 50 and b is 100 and c is 5 c) a is 3 and b is 7 and c is 10 a is 25 and b is 5 and c is 24 a is 100 and b is 5 and c is 50 d) None of the mentioned Answer: c What is the output of below program? def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: return y print(maximum(2, 3)) a) 2 b) 3 c) The numbers are equal d) None of the mentioned Answer: b What is the output of below program? def cube(x): return x * x * x x = cube(3) print x a) 9 b) 3 c) 27 d) 30 Answer: c What is the output of the below program? def C2F(c): return c * 9/5 + 32 print C2F(100) print C2F(0) a) 212 and 32 b) 314 and 24 c) 567 and 98 d) None of the mentioned Answer: a What is the output of the below program? def power(x, y=2): r = 1 for i in range(y): r = r * x return r print power(3) print power(3, 3) a) 212 and 32 b) 9 and 27 c) 567 and 98 d) None of the mentioned Answer: b What is the output of the below program? def sum(*args): '''Function returns the sum of all values''' r = 0 for i in args: r += i return r print sum.doc print sum(1, 2, 3) print sum(1, 2, 3, 4, 5) a) 6 and 15 b) 6 and 100 c) 123 and 12345 d) None of the mentioned Answer: a What is the output of this program? y = 6 z = lambda x: x * y print z(8) a) 48 b) 14 c) 64 d) None of the mentioned Answer: a What is the output of below program? lamb = lambda x: x ** 3 print(lamb(5)) a) 15 b) 555 c) 125 d) None of the mentioned Answer: c What is the output of below program? def writer(): title = 'Sir' name = (lambda x:title + ' ' + x) return name who = writer() who('Arthur') a) Arthur Sir b) Sir Arthur c) Arthur d) None of the mentioned Answer: b What is the output of the following piece of code? def a(b): b = b + [5] c = [1, 2, 3, 4] a(c) print(len(c)) a)4 b)5 c)1 d)An exception is thrown Answer: b What is the output of the following code? i=0 def change(i): i=i+1 return i change(1) print(i) a)1 b)Nothing is displayed c)0 d)An exception is thrown Answer: c What is the output of the following code? a=10 b=20 def change(): global b a=45 b=56 change() print(a) print(b) a)10 and 56 b)45 and 56 c)10 and 20 d)Syntax Error Answer: a

ChapterwiseMCQ.pdf5.71 KB

Ans. b) ii and iii [48] Pickling refers to a) converting the structure to a byte stream before working to the file b) converting the structure to a file in unicode c) converting the structure to a file in text file d) converting the structure to a csv filve Ans. a) converting the strucgture to a byte stream before working to the file [49] The process of converting the byte stream into its original form back is known as a) pickling b) unpickling c) decomposition d) composition Ans. b) Unpickling [50] The dump method requires _________ minimum no of parameters a) 1 b) 2 c) 0 d) None of these Ans. b) 2 [50] Whic of the following parameters required for pickle.dump() method a) object, fileobject b) fileobject, object c) filename, filemode d) None of these Ans. a) file, objectfile [51] User need to call load() each time dump() is called. a) Yes, it must be b) No, Not necessarily c) Depends on the file operations d) All of the above Ans. a) Yes, It must be [52] Which of the following function is used to write steam data from python console to binary file? a) load() b) dumps() c) dump() d) write() Ans. c) dump [53] The pickle.load() function requires minimum _____ number of parameters a) 0 b) 1 c) 2 d) 3 Ans. b) 1 [54] To read binary files data ___________ function is used. a) read() b) readdata() c) dump() d) load() Ans. d) load() [55] Arrange the following file handling operations in proper order: A) Close the file B) Perform operations on file C) Opening the file a) C – B – A b) A – B – C c) A – C – B d) C – B – A Ans. d) C – B – A [56] Observe the following code: f=open('story.txt','r') for i in ____: print(i,end="") f.close() a) range(f) b) f c) len(f) d) None of these Ans. b) f [57] Rani wants to replace the for loop given in the above question: a) for i in f.readline(): b) for i in f.read(): c) for i in f.readlines(): d) for i in range(len(f)): Ans. c) for i in f.readlines() [57] Observe the following code that reads the text file ‘para.txt’, choose the correct line code to count and print those lines end with full stop or comma. c=0 with open(“para.TXT “,”r”) as f: for i in f: ______________________ c=c+1 print(“count=”,c) a) if i[len(i)-2]==’.’ or i[len(i)-2]==’,’ : b) if i[len(i)]==’.’ or i[len(i)]==’,’: c) if i==’.’ or i==’,’ d) if ‘.’ in i or ‘,’ in i: Ans. a)

Ans. a) write() [35] The write() function actually a) writes into permanent location to the file b) write into the buffer c) write into the library d) write into the program Ans. b) write into buffer [36] Jenny wants to transfer data into csv from the python console screen. Which of the following is the correct statement to import the module csv in python? a) import csv as cv b) import csv_file as cv c) import CSV as cv d) import csv.* Ans. a) import csv as cv [37] To write data into CSV from python console, which of the following function is correct? a) csv.write(file) b) csv.writer(file) c) csv.Write(file) d) csv.writerow() Ans. b) csv.writer(file) [38] Python will raise error FileNotFounderror, if a) the file is empty b) the file is created but not in use c) the file doesn’t exist d) the file is opened in read mode Ans. c) the file doesn’t exist [39] Vansh has created a file names ‘data.txt’. Now he wants to add content as like that data will be added into the file without erasing old data. Kindly share your views by filling up this feedback form. Select the appropriate code to do so. a) f=open(“data.txt”, ‘w’) b) f=open(“data.txt”,’r’) c) f=open(“data.txt”,’wb’) d) f=open(“data.txt”,’a’) [40] The alternative statement of f.close() is a) f=close() b) f.exit() c) f.quit d) with statement ”Answer” [41] Using with ensures that i) all the resources allocated the file objects get deallocated automatically when the user stops using the file ii) all files will be closed by itself iii) do not require to close the file in case of exception as well iv) it makes code more compact and readable a) i, ii and iii b) i, iii and iv c) ii, ii and iv d) ii, iii and iv ”Answer” [42] which of the following is the correct statement for with statement? a) f = open with(‘data’txt’,’w’) b) with (‘data.txt’,’w’) c) with open(‘data.txt’,’w’) as f: d) with open=(‘data.txt’,’w’) as f: Ans. c) with open(‘data.txt’,’w’) as f: [43] Mr. Alpesh wants to know the standard stream which reads the standard input in python. Select the correct stream from the following: a) sys.stdin b) sys.stdinput c) sys.input d) sys.standardin Ans. a) sys.stdin [44] To use the standard streams, which of the following module can be used? a) pickle b) system c) sys d) standard Ans. c) sys [45] Statement A: Data written to sys.stdout appears on screen. Statement B: Data are written to sys.stdout can be linked to the standard input of another program with a pipe. a) Statement A is True b) Statement B is False c) Statement B is True d) Both statements A and B are True Ans. d) Both statements A and B are True [46] Select the correct statements for sys.stderr: i) It is used to provide error messages. ii) It is similar as sys.stdout iii) It does not print only exceptions but prints error messages with debugging comments iv) Can be linked to the standard input of another program with a pipe symbol a) ii, iii and iv b) i, ii and iv c) i and iv only d) i, ii and iii Ans. d) i, ii and iii [47] The process of transforming data or an object in RAM to a stream of bytes is _______. i) Transformation ii) Pickling iii) Serialization iv) Deserialization a) i and ii b) ii and iii c) iii and iv d) i and iv

Ans. a) os [19] Manoj wants to get the name of the current directory. Select appropriate statement for the same: a) os.getcd() b) os.getcurrentdirectory() c) os.getcwd() d) os.currentdirectory() Ans. c) os.getcwd() [20] Identify the function to read first 5 characters of the file from the beginning out of the following: a) f.read(5) b) f.read()=5 c) f.readline() d) f.readlines(5) Ans. a) f.read(5) [21] Priya has placed the file pointer at 4th line in the text file. Now she wants to read all remaining lines of a text file. Which function is suitable for her, select the correct one: a) f.read() b) f.readlines() c) f.read(n) d) f.readlines() Ans. d) f.readlines() [22] A file customer.txt has been created. Now Which of the following function(s) can be used to open the file in only reading mode? i) f=open(“customer.txt”,’r’) ii) f=open(“customer.txt”,’r+’) iii) f=open(“customer.txt”) iv) f=open(“customer.txt”,”rb”) a) i and iii only b) i, ii and iii c) ii and iii d) iv only Ans. a) i and iii Only [23] In which of the following mode the file offset position is not at the begging of the file? i) r, rb, r+ or +r, rb+ or +rb ii) w, wb, wb+ or +wb iii) a, a+ or +a a) i, ii and iii b) i, and ii only c) iii only d) ii and iii only ”Answer” [24] Which of the following statement is correct for opening file for read and write both mode? a) r b) rb c) a d) r+ or +r ”Answer” [24] Puru wants to close a file after reading operation for the file object f. Suggest the correct function to him. a) f.close() b) f.close c) f.quit() d) f.exit() Ans. a) f.close() [25] Statement A: It is always a good practice to close the file when read/write operations done in the file. Statement B: While closing a file system frees the memory allocated to it. a) Statement A is Correct b) Statement B is Correct c) Statement A and Statement B are correct d) Statement A and Statement B are incorrect Ans. c) Statement A and Statement B are correct [26] Disha is looking for a function to write a stream of bytes in the text file. Which of the following function is correct? a) write() b) writestream() c) writestatement() d) writeline() Ans. d) writeline() [27] Atul wants to know that he has closed the file after performing the tasks. Which of the following function he can used to check whether the file is closed or not? a) f.close() b) f.closing() c) f.closed() d) There is no such function in python Ans. c) f.closed() [28] The access_mode can be retrieved through a) access_mode b) process_mode c) open_mode d) select_mode Ans. a) access_mode [29] Which of the following statement is correct about the file closing? a) If the file object is re-assigned to another file, the previous file is automatically closed b) every time you need to close the file when you want to re-assign file object to another file c) re-assign file object to another file is not possible in python d) None of these Ans. a) [30] _________ clause close the opened file automatically once control comes outside the clause. a) for clause b) while clause c) with clause d) None of these Ans. c)with clause [31] The with clause plays an important role in file handling when a) File is opened for writing b) File is opened for reading c) File is closed d) Exception occurs Ans. d) Exception Occurs [32] Statement A: An existing file is opened in the write mode the previous data will be erased. Statement B: When the existing file is opened in write mode the file object will be positioned at the end of the file. a) Statement A is Wrong b) Statement B is wrong c) Statement A and B both are wrong d) Statement A and B both are correct Ans. b) Statement B is wrong [33] The ________ mode allows adding data into the existing file at the end of the file. a) read b) write c) binary d) append Ans. d) append [34] Which of the following function requires a new line character at the end of every sentence to mark the end of line in writing mode? a) write() b) writeline() c) writelines() d) dump()

Data File handling MCQs Class 12 – MCQ Term 1 Computer Science Class 12 [1] A ______________ is a bunch of bytes stored on some storage devices like hard-disk, pen-drive etc. a) Folder b) File c) Package d) Library Ans. b) File [2] The ____________ are the files that store data pertaining to a specific application, for later use. a) Data File b) Program File c) Source Code d) Program Code Ans. a) Data File [3] Which of the following format of files can be created programmatically through python program? a) Data Files b) Video Files c) Media Files d) Binary Files Ans. d) Binary Files [4] Suketu is learning the concept of file handling in python. Where he knew that a type of file stores information in ASCII or UNICODE characters and each line is terminated by EOL. But he forgets the file type. Select the appropriate file type for the same. a) ASCII File b) Data File c) Text File d) Binary File Ans. c) Text File [5] Supriya doesn’t know about the text file extension. Help her to identify the same out of these: a) .text b) .txt c) .txf d) .tfx [6] In python which of the following is the default EOL character? a) \eol b) \enter c) \n d) \newline Ans. c) \n [7] Which of the following statement is correct for binary files? a) The file content returned to user in raw form b) Every line needs translation c) Each line is terminated by EOL d) It stores ASCII or Unicode characters Ans. a) The file content returned to user in raw form [8] Which of the following statement is not correct for text file? A) Contains the information as same as its held in memory B) No delimiter for a line C) read and write faster than binary files D) Common format for general work a) A and B only b) A, B and C c) A, C and D d) All of them Ans. d) All of them [9] Shiv wants to store the data of his customer using the python program. Suggest the best way to store the data? a) Text Files b) CSV files c) Binary Files d) Module File Ans. c) Binary File [10] A basic approach to share large data among different organizations carried out through a) text files b) binary files c) spreadsheets or database d) email attachments Ans. c) spreadsheets or database [11] A ___________ is a simple flat file in a human-readable format that is used to store data in a spreadsheet or database. a) text file b) database file c) binary file d) CSV file Ans. CSV File [12] Which of the following statement is correct for CSV files? a) Store data in plain text b) Stores data in raw form c) Stores data in ASCII or Unicode encoded form d) Store data in converted form Ans. a) Store data in plain text [13] The CSV files can be accessed by a) text editor and spreadsheet software b) only through python programs c) Only spreadsheet software d) Only through database software ”Answer” [13] Each line in CSV file is known as a) tuple b) data/record c) field d) format ”Answer” [14] Read the statements and choose the correct answer: Statement A: It is very difficult to organize unstructured data Statement B: CSV helps into organize a huge amount of data in a proper and systematic way a) Only Statement A is correct b) Only Statement B is correct c) A and B both are correct d) None of them is correct Ans. c) A and B both are correct [15] Which of the following are features of CSV files: a) easy to read and manage b) small in size c) fast to process data d) All of them ”Answer” [16] While opening a file for any operation python looks for a) File in the system folder b) file in the python installation folder c) file in the current folder where the .py file is saved d) file in the downloads folder Ans. c) file in the current folder where the .py file is saved [17] The default directory for performing most of the functions is known as a) active directory b) current directory c) working directory d) open directory Ans. b) current directory [18] Biswajit wants to working with files and directories through python. Select the python module to help him to do finish his work: a) os b) csv c) pickle d) sys

c) All lines are correct and no errors [32] What will be the output of the following: def Val(m,n): for i in range(n): if m[i]<30: m[i]//=5 elif m[i]%5 == 0: m[i]//=3 else: m[i]//=2 l = [25,8,75,12] Val(l,4) for i in l: print(i,end="$") a) 1$1$2$25$2$ b) 5$1$25$2$ c) 1$4$25$3$ d) 5$2$15$2$ b) 5$1$25$2$ [33] What will be the output of the following code: def or_cap_update(pl,r,i): pl['Runs']+=r pl['Innings']+=i pl1={'S.No':1,'Name':'K L Rahul','Runs':528,'Innings':12} pl2={'S.No':2,'Name':'Rituraj Gaikwad','Runs':521,'Innings':13} or_cap_update(pl1,35,1) or_cap_update(pl2,35,1) print(pl1) print(pl2) a) {‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 35, ‘Innings’: 1} {‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 35, ‘Innings’: 1} b) {‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 563, ‘Innings’: 13} {‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 556, ‘Innings’: 14} c) {‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 528, ‘Innings’: 12} {‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 521, ‘Innings’: 13} d) {‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 528, ‘Innings’: 1} {‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 521, ‘Innings’: 1} Ans. b) {‘S.No’: 1, ‘Name’: ‘K L Rahul’, ‘Runs’: 563, ‘Innings’: 13} {‘S.No’: 2, ‘Name’: ‘Rituraj Gaikwad’, ‘Runs’: 556, ‘Innings’: 14} [34] Which of the following variable is defined outside the function? a) local b) global c) enclosed d) All of these Ans. b) global [35] Observe the following code and select appropriate answers for the given questions: total = 1 def multiply(l):#Line 1 for x in l: _______ total #Line2 total *= x return _______ #Line3 - Reutrn varibale l=[2,3,4] print(multiply(_____),end="") # Line4 print(" , Thank you ") 1. Identify the part of function in #Line1? o Function header o Function Calling o Return statement o Default Argument 2. Which of the keyword is used to fill in the blank for #Line2 to run the program without error? o eval o def o global o return 3. Which variable is going to be returned in #Line3 o total o x o l o None 4. Which variable is required in the #Line4? o total o x o l o None 5. In the line #Line4 the multiply(l) is called __________ o caller o called o parameter o argument 6. In function header multiply(l), l refers to ____________ o caller o called o parameter o argument 7. In function calling multiply(l), l refers to ___________ o caller o called o parameter o argument 8. What will be the output of this code? o 2 3 4 , Thank you o 234 , Thank You o 24 , Thank you o Thank You 9. Which of the following statement indicates the correct staement for the formal paramter passing technique? o multiply(l) o multiply(l=[23,45,66]) o multiply([23,45,66]) o multiply(23,45,66) 10. Which of the following statement indicates the correct staement for the actual paramter passing technique? o multiply(l) o multiply(l=[23,45,66]) o multiply([23,45,66]) o multiply(23,45,66) 11. Sonal wants to modify the function with the specification of length of list with default argument statement for the function with the list and 10 elements by default. Which of the following statement is correct? o def multiply(n=10,l): o def multiply(l,n=10): o def multiply(l,10): o def myultiply(l=[22,34,56,22,33,12,45,66,7,1]) 12. Diya wants to call the function with default argument value in the function to display the product of list tobject l. Select the correc statement for her to the same. o multiply(l) o multiply(10) o multiply(l,n) o multiply(n,l) Answers function Case study based MCQ 1. a) Function Header 2. c) global 3. a) total 4. c) l 5. a) caller 6. b) argument 7. c) parameter 8. c) 24, Thank You 9. a) multiply(l) 10. c) multiply([23,45,66]) 11. b) def multiply(l,n=10) 12. a) multiply(l)

Ans. c) D -> E-> -> A -> B -> C -> F 18. What is the maximum and minimum value of c in the following code snippet? import random a = random.randint(3,5) b = random.randint(2,3) c = a + b print(c) a) 3 , 5 b) 5, 8 c) 2, 3 d) 3, 3 Ans. b) 5,8 19. By default python names the segment with top-level statement as __________________ a) def main() b) main() c) main d) _main Ans. c) main 20. The order of executing statements in a function is called a) flow of execution b) order of execution c) sequence of execution d) process of execution Ans. a) flow of execution 21. In python function, the function calling another function is known as ________________ and the function being called is known _________ a) main, keyword b) caller, called c) called, caller d) executer, execute Ans. b) caller, called 22. Archi is confused between arguments and parameters. Select the fact about argument and parameter and solve her doubt a) arguments are those values being passed and parameters are those values received b) parameters are those values being passed and arguments are those values received c) arguments appear in the function header and parameters appear in the function call d) arguments can have same name and parameters can have value type Ans. a) arguments are those values being passed and parameters are those values received 23. The value is passed through a function call statement is called _________ and the values being received in the definition is known as __________ a) formal parameter, actual parameter b) actual parameter, formal parameter c) passed parameter, received parameter d) value parameter, constant parameter Ans. b) actual parameter, formal parameter 24. The positional parameters are also known as a) required arguments b) mandatory arguments c) Both a and b d) None of them Ans. c) Both a and b 25. Which of the following is true about the default argument a) default values are provided in the function call b) default values are provided in the function body c) default values are provided with the return statement d) default values are provided in the function header Ans. d) default values are provided in the function header 26. The default valued parameter specified in the function header becomes optional in the function calling statement. a) Yes b) No c) Not Sure d) May be Ans. a) Yes 27. Which of the following function header is correct : a) def discount(rate=7,qty,dis=5) b) def discount(rate=7,qty,dis) c) def discount(rate,qty,dis=5) d) def discount(qty,rate=7,dis) Ans. c) def discount(rate,qty,dis=5) 28. Read the following statements and then select the answer: Statement A: Default arguments can be used to add new parameters to the existing functions Statement B: Default arguments can be used to combine similar functions into one a) Statement A is correct b) Statement B is correct c) Both are correct d) Both are incorrect Ans. c) Both are correct 29. What will be the output of the following code? def fun(x=10, y=20): x+=5 y = y - 3 return x*y print(fun(5),fun()) a) 20, 200 b) 170, 255 c) 85, 200 d) 300, 500 Ans. b) 170, 255 30. What will be the output of the following code? v = 80 def display(n): global v v = 15 if n%4==0: v += n else: v -= n print(v, end="#") display(20) print(v) a) 80#80 b) 80#100 c) 80#35 d 80#20 Ans. c) 80#35 Watch this video for an explanation: 31. Observe the following lines written for the calling statement and select the appropriate answer: ele_bill(past_reading=200,rate=6,current_reading=345) ele_bill(current_reading=345,rate=6,past_reading=200) ele_bill(rate=6,past_reading=200,current_reading=345) a) all lines have errors b) Only line 1 will execute and the rest will raise an error c) All lines are correct and no errors d) only line 3 is correct

Working with functions Computer Science Class 12 1. Aman wants to write a function in python. But he doesn’t know how to start with it! Select the keyword used to start a function out of the following: a) function b) start c) def d) fun Ans. c) def 2. Which of the following is a valid function name? a) start_game() b) start game() c) start-game() d) All of the above Ans. a) start_game() 3. Which of the following is not a part of the python function? a) function header b) return statement c) parameter list d) function keyword Ans. d) function keyword 4. If the return statement is not used in the function then which type of value will be returned by the function? a) int b) str c) float d) None Ans. d) None 5. The function header contains a) function name and parameters only b) def keyword along with function name and parameters c) return statement only d) parameter list only Ans. b) def keyword along with function name and parameters 6. The subprogram that acts on data and returns the value sometimes is known as a) Function b) Module c) Class d) Package Ans. a) Function 7. Read the statements: Statement (A) : A function can perform certain functionality Statement (B) : A function must return a result value a) Statement A is correct b) Statement B is correct c) Statement A is correct but Statement B is not correct d) Both are incorrect Ans. c) Statement A is correct but Statement B is not correct 8. Richa is working with a program where she gave some values to the function. She doesn’t know the term to relate these values. Help her by selecting the correct option. a) function value b) arguments or parameters c) return values d) function call Ans. b) arguments of parameters 9. Mohini wants to know that the symbol : (colon) must be required with which of the following function part? a) function header d) function body c) return statement d) parameters Ans. a) function header 10. Which of the function part contains the instructions for the tasks to be done in the function? a) function header d) function body c) return statement d) parameters Ans. b) function body 11. Ananya is trying to understand the features of python functions. She is not understanding the feature that distributes the work in small parts. Select the appropriate term for her out of the following: a) Modularity b) Reusability c) Simplicity d) Abstraction Ans. a) Modularity 12. Which of the following is not a feature supported by python functions a) Modularity b) Reusability c) Simplicity d) Data Hiding Ans. d) Data Hiding 13. Divya wants to print the identity of the object used in the function. Which of the following function is used to print the same? a) identity() b) ide() c) id() d) idy() Ans. c) id() 14. Rashmin is learning the python functions He read the topic types of python functions. He read that functions already available in the python library is called ___________. Fill appropriate word in this blank : a) UDF (User Defined Function) b) Built-in Functions c) Modules d) Reusable Function Ans. b) Built-in functions 15. Which of the following sentence is not correct for the python function? a) Python function must have arguments b) Python function can take an unlimited number of arguments c) Python function can return multiple values d) To return value you need to write the return statement Ans. a) Python function must have arguments 16. Pranjal wants to write a function to compute the square of a given number. But he missed one statement in the function. Select the statement for the following code: def sq(n): ____________ print(sq(3)) a) return square of n b) return n**2 c) return n d) print(“n**n”) Ans. b)return n**2 17. Select the proper order of execution for the following code: A. def diff(a,b): B. c=a-b C. print(“The Difference is :”,c) D. x,y =7,3 E. diff(x,y) F. print(“Finished”) a) A -> B -> C -> D -> E -> F b) D -> E -> F -> A -> B -> C c) D -> E -> A -> B -> C -> F d) E -> B -> C -> D -> A -> F

Warm Welcome to all. ⭐ SRM Institute of Science and Technology, Ramapuram Campus, Chennai, India⭐ ⭐ Department of Computer Science and Engineering⭐ We are pleased to invite you all to join us for the event. Event Name: *"IGNITE'23 : INTRODUCTION TO ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING"* Date & Time: 03-03-2023, Time: 06:00 P.M to 07:00 P.M Participants Senior Secondary School Students. Registration Link https://forms.gle/BJxweJjbwuW2E3to6 Join through the Google Meet Link https://meet.google.com/bhk-cmxk-idb E-Certificate will be issued for all active participants Convener Dr. K. Raja, HOD/CSE Faculty Co-ordinators: Mr.M.Sadhasivam, AP/CSE Mr.S.Ezra Vethamani, AP/CSE

1. https://t.me/askpythonquestions 2. https://t.me/cbsecomputerscience 3. https://t.me/todayweareaslearners 4. Python Basics-1 t.me/QuizBot?start=ayrNqFKS 5. Python List-1 t.me/QuizBot?start=eowBkzeL 6. Python List-2 t.me/QuizBot?start=k8DYZ3Oa 7. Python List-3 t.me/QuizBot?start=Smn9ThxH 8. Python FILE HANDLING -1 t.me/QuizBot?start=nQD1Q3kG 9. Python FILE HANDLING -2 t.me/QuizBot?start=vx12PVG3 10. Python FILE HANDLING -3 t.me/QuizBot?start=7VvdcQtz 11. Python FILE HANDLING -4 t.me/QuizBot?start=MnPrt2v4 12. Python FILE HANDLING -5 t.me/QuizBot?start=ohtwqD6S

photo content

my_dict={} my_dict[(1,2,4)]=8 my_dict[(4,2,1)]=10 my_dict[(1,2)]=12 sum=0 for k in my_dict: sum+=my_dict[k] print(sum) print(my_dict) OUTPUT: 30 {(1, 2, 4): 8, (4, 2, 1): 10, (1, 2): 12}

FList1=['apple','berry','cherry','papaya'] FList2=FList1 FList3=FList1[:] #print(FList1,FList2,FList3,sep='\n') FList2[0]='guava' #print(FList1,FList2,FList3,sep='\n') FList3[1]='kiwi' #print(FList1,FList2,FList3,sep='\n') sum=0 for i in (FList1,FList2,FList3): if i[0]=='guava': sum+=1 if i[1]=='kiwi': sum+=20 print(i,' Sum = ',sum) input("Press any key to continue...") print(sum) OUTPUT ['guava', 'berry', 'cherry', 'papaya'] Sum = 1 Press any key to continue... ['guava', 'berry', 'cherry', 'papaya'] Sum = 2 Press any key to continue... ['apple', 'kiwi', 'cherry', 'papaya'] Sum = 22 Press any key to continue... 22

In first case, String '100' is iterable so output becomes '1','0','0' but in second case integer 100 is not iterable so it having type error

photo content

photo content