This quiz works best with JavaScript enabled. Home > Cbse > Class 12 > Science > Computer Science > Class 12 Computer Science Chapter 2 Advanced Python Programming – Quiz 2 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 2 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which of the following is also known as brain of computer? A) Control unit. B) Central Processing unit. C) Arithmetic and language unit. D) Monitor. Show Answer Correct Answer: B) Central Processing unit. 2. Python is considered to be a (a) programming language. A) Procedural Programming Language. B) A. Object-Oriented Programming Languag. C) Assembly Language. D) Functional Programming Language. Show Answer Correct Answer: B) A. Object-Oriented Programming Languag. 3. What does the command 'print("Hello, Python!")' do? A) Creates a variable. B) Exits the program. C) Saves 'Hello, Python!' to a file. D) Prints 'Hello, Python!'. Show Answer Correct Answer: D) Prints 'Hello, Python!'. 4. Which function can be used to combine dataframes based on common fields? A) Merge(). B) Combine first(). C) Concat(). D) None of the above. Show Answer Correct Answer: A) Merge(). 5. Which of the following is the type of the computer network? A) Metropolitan area network (MAN). B) Local area network (LAN). C) Wide area network (WAN). D) All of the above. Show Answer Correct Answer: D) All of the above. 6. Full form of NaN is A) Not a Null. B) Not a Number. C) Not a Numeric. D) None of these. Show Answer Correct Answer: B) Not a Number. 7. Select the correct sql statement for print records from a database table emp A) Select all from emp. B) Select * from emp. C) Select * from emp;. D) Select * from emp( );. Show Answer Correct Answer: C) Select * from emp;. 8. What will be the output of this statement?>>>"a"+"bc" A) A bc. B) A. C) Abc. D) A+bc. Show Answer Correct Answer: C) Abc. 9. DataFramedf Age Namerank1 28 Tomrank2 34 Jackrank3 29 Steverank4 42 RickyFind out the command used to get the following output from the above dataframe, Age rank1 28 rank2 34 rank3 29 rank4 42 A) Print(df('Age')). B) Print(df['Age']). C) Print(df['Age'], axis=1). D) Print(df['Age']). Show Answer Correct Answer: B) Print(df['Age']). 10. How do you pass arguments to a Python function? A) Arguments are passed to a Python function by placing them inside the parentheses of the function call. B) Arguments are passed to a Python function by telepathy. C) Arguments are passed to a Python function by writing them on a piece of paper and mailing it. D) Arguments are passed to a Python function by sending them via email. Show Answer Correct Answer: A) Arguments are passed to a Python function by placing them inside the parentheses of the function call. 11. Which one of the following is correct way of declaring and initializing a variable, x with value 5?int x A) Declare x=5. B) Int x=5. C) Int x=5. D) X=5. Show Answer Correct Answer: D) X=5. 12. What is the output of the following program?for i in range(0, 5):print(i) i=i+1 A) 0 to 4 numbers. B) 0 to 5 numbers. C) 1 to 4 numbers. D) 1 to 5 numbers. Show Answer Correct Answer: A) 0 to 4 numbers. 13. Among the following functions, which one can be used to combine dataframes when they have similar structure. A) Combine first. B) Concat(). C) Merge(). D) None of the above. Show Answer Correct Answer: B) Concat(). 14. Write the output:import pandas as pd1 s = pd1.Series([1, 2, 3]) t = pd1.Series([1, 2, 4]) u=s-t print (u) A) 0 01 02-1dtype:float64. B) 0 01 02 1dtype:int64. C) 0 11 02 1dtype:int64. D) 0 01 02-1dtype:int64. Show Answer Correct Answer: D) 0 01 02-1dtype:int64. 15. What will be the output?str1 = "Deep Learning"print (len(str1)) A) 11. B) Out of Range Error. C) 12. D) 13. Show Answer Correct Answer: D) 13. 16. Which of the following is incorrect variable name in Python? A) 1variable. B) Variable1. C) Variable 1. D) Variable. Show Answer Correct Answer: A) 1variable. 17. What does IDLE stand for? A) Information Development Environment. B) Interactive Development Environment. C) Image Development Environment. D) Integrated Development Environment. Show Answer Correct Answer: D) Integrated Development Environment. 18. Write the output for the following:import pandas as pd1 s = pd1.Series(5, index=[0, 1, 2, 3]) print(s) A) 0 5 1 5 2 5 3 5 dtype:object. B) 1 5 2 5 2 5 4 5 dtype:int64. C) 0 5 1 5 2 5 3 5 dtype:int64. D) 0 5. Show Answer Correct Answer: C) 0 5 1 5 2 5 3 5 dtype:int64. 19. Which one of the following if statements will not execute successfully?1) if (1, 2);print('foo')2) if (1, 2):print('foo')3) if (1):print( 'foo' )4) if (1);print( 'foo' ) A) 4. B) 2, 4. C) 1, 4. D) 2. Show Answer Correct Answer: D) 2. 20. Identify the arithmetic operator which is used to calculate exponential. A) **. B) *. C) %. D) !. Show Answer Correct Answer: A) **. 21. How do you take user input in Python using the input() function? A) Assign the input() function to a variable without a prompt message. B) Use the input() function without parentheses. C) Use the print() function to get user input. D) Call the input() function with a prompt message as an argument. Show Answer Correct Answer: D) Call the input() function with a prompt message as an argument. 22. Which of the following is NOT a key feature of Object-Oriented Programming in Python? A) Classes. B) Compilation. C) Objects. D) Encapsulation. Show Answer Correct Answer: B) Compilation. 23. Which of these is the definition for packages in Python? A) A set of main modules. B) A folder of python modules. C) A number of files containing Python definitions and statements. D) A set of programs making use of Python modules. Show Answer Correct Answer: C) A number of files containing Python definitions and statements. 24. S = pd.series([1, 2, 3, 4, 5], index=['a', 'b', 'c', 'd', 'e'])print(s[:3] gives? A) A 1b 2c 3. B) A 1b 2c 3d 4. C) A 3b 4c 5. D) None of the above. Show Answer Correct Answer: A) A 1b 2c 3. 25. What symbol is used to pass an arbitrary number of arguments to a Python function? A) ++. B) &. C) **. D) *. Show Answer Correct Answer: D) *. 26. Which of these is mutable? A) List. B) Tuple. C) String. D) None of the above. Show Answer Correct Answer: A) List. 27. We can iterate over string A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 28. Which functions are used to accept input from the user. A) Input(). B) String(). C) Raw input(). D) Rawinput(). Show Answer Correct Answer: A) Input(). 29. Predict the output of the following code:x=3If x>2 or x<5 and x==6:Print( "ok" )else:print( "no output" ) A) Ok. B) Okok. C) No output. D) None of above. Show Answer Correct Answer: C) No output. 30. In Python an ELSE IF statement is represented as what? A) Elsif. B) Elseif. C) Elif. D) Ifelse. Show Answer Correct Answer: C) Elif. 31. Which of these collections defines a TUPLE? A) {"name": "apple", "color": "green"}. B) ["apple", "banana", "cherry"]. C) ("apple", "banana", "cherry"). D) {"apple", "banana", "cherry"}. Show Answer Correct Answer: C) ("apple", "banana", "cherry"). 32. Which function opens a file for reading in Python? A) Open(). B) FileOpen(). C) OpenFile(). D) ReadFile(). Show Answer Correct Answer: A) Open(). 33. How can you check if Python is installed on your system? A) By checking the file extension. B) By searching in the start bar. C) By using a web browser. D) By running a Python script. Show Answer Correct Answer: B) By searching in the start bar. 34. What is the output of the expression '3 * 2 ** 2' in Python? A) 9. B) 12. C) 8. D) 6. Show Answer Correct Answer: A) 9. 35. Which of the following is correctly evaluated for this function?pow(x, y, z) A) (x / y) / z. B) (x**y) % z. C) (x**y) / z. D) (x / y) * z. Show Answer Correct Answer: B) (x**y) % z. 36. We can insert the new item into tuple A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 37. IN WHICH YEAR WAS THE PYTHON PROGRAMMING LANGUAGE DEVELOPED? A) 1989. B) 1972. C) 1981. D) 1995. Show Answer Correct Answer: A) 1989. 38. Which of the following is the correct way to declare a variable and assign an integer value in Python? A) X:= 10;. B) Int x = 10;. C) X = 10. D) Var x = 10;. Show Answer Correct Answer: C) X = 10. 39. Identify the DDL commands A) Create, alter, drop, trucate, rename. B) Insert, update, delete, select. C) Create, insert, drop, update. D) Grant, revoke. Show Answer Correct Answer: A) Create, alter, drop, trucate, rename. 40. What is the correct syntax for defining a class named 'Vehicle'? A) Class Vehicle(). B) Class Vehicle[]. C) Class Vehicle:. D) Class Vehicle:{}. Show Answer Correct Answer: C) Class Vehicle:. 41. What is the use of the 'import' statement? A) To create a variable in the current scope. B) To define a new function in a program. C) To include external modules or libraries in a program. D) To execute a program from the command line. Show Answer Correct Answer: C) To include external modules or libraries in a program. 42. What are the different types of conditional statements in Python? A) When. B) If, elif, else. C) Otherwise. D) Unless. Show Answer Correct Answer: B) If, elif, else. 43. What is the outupt of the following code:m=[23, 11, 6, 7, 8, 9, 21]print(m[2:20:2]) A) Error due to index out of range. B) [11, 6, 7, 8, 9]. C) [11, 7, 9]. D) [6, 8, 21]. Show Answer Correct Answer: D) [6, 8, 21]. 44. What does the command '"hello" + "world"' do? A) Creates a new variable. B) Concatenates the strings. C) Prints 'hello world'. D) Repeats the string. Show Answer Correct Answer: B) Concatenates the strings. 45. The purpose of bg in Tkinter widget is to ..... A) To change the size of widget. B) To change the background of widget. C) To change the direction of widget. D) To change the color of widget. Show Answer Correct Answer: B) To change the background of widget. 46. What will be the output of above Python code?str1="6/4"print("str1") A) Str1. B) 6/4. C) 1. D) 1.5. Show Answer Correct Answer: A) Str1. 47. It is possible to draw a circle directly in Tkinter canvas? A) Yes. B) No. C) No(but possible by oval). D) None of the above. Show Answer Correct Answer: C) No(but possible by oval). 48. What is the purpose of a function in Python? A) The purpose of a function in Python is to encapsulate a set of instructions that can be reused and called multiple times within a program. B) The purpose of a function in Python is to print a specific value to the console. C) The purpose of a function in Python is to stop the execution of the program. D) The purpose of a function in Python is to create a new variable. Show Answer Correct Answer: A) The purpose of a function in Python is to encapsulate a set of instructions that can be reused and called multiple times within a program. 49. Which library is used to connect python with MySQL? Write an import statement A) Import mysql.connector(). B) Import mysql.connector() as msq. C) Import mysql.connector. D) Import mysql connector.connect. Show Answer Correct Answer: A) Import mysql.connector(). 50. Which of the following is the output of the below Python code?[Note:Python 2.7.5 and above]mylist=['a', 'aa', 'aaa', 'b', 'bb', 'bbb']print(mylist[int(-1/2)]) A) B. B) 'bbb'. C) A. D) Bbb. Show Answer Correct Answer: C) A. 51. Which of the following is a benefit of Python's broad standard library? A) It is very portable and cross-platform compatible. B) It is only for web applications. C) It is only available on Windows. D) It requires a lot of memory. Show Answer Correct Answer: A) It is very portable and cross-platform compatible. 52. What is the output of the following program?L1 = [1, 2, 3, 4]L2 = L1L3 = L1.copy()L4 = L3L1[0] = [5]print(L1, L2, L3, L4) A) [5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4][1, 2, 3, 4]. B) [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]. C) [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]. D) [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]. Show Answer Correct Answer: B) [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]. 53. Screen inside another screen is possible by creating ..... A) Another window. B) Labels. C) Frames. D) Buttons. Show Answer Correct Answer: C) Frames. 54. ..... method is used to draw a line in canvas tkinter A) Create line(). B) Create line(canvas). C) Canvas.create line(). D) Line(). Show Answer Correct Answer: C) Canvas.create line(). 55. Which method of cursor class is used to fetch records from the table A) Cur.fetchall(). B) Cur.fetchone(). C) Cur.fetchmnay(). D) Cur.fetch(). Show Answer Correct Answer: A) Cur.fetchall(). 56. Which of the following is the output of the Python code fragment given below?var1 = 4.5var2 = 2print(var1//var2) A) 2.0. B) 22.5. C) 2.5. D) 2.25. E) 20.0. Show Answer Correct Answer: A) 2.0. 57. Which of the following statements create a dictionary? A) D = {}. B) D = {"john":40, "peter":45}. C) D = {40:"john", 45:"peter"}. D) All of the mentioned. Show Answer Correct Answer: D) All of the mentioned. 58. The keyword used to import the Tkinter in program is ..... A) Call. B) From. C) Import. D) Use. Show Answer Correct Answer: C) Import. 59. What will be the output?d = 10 < 11print (d) A) 11. B) False. C) True. D) 10. Show Answer Correct Answer: C) True. 60. In Python, what happens if you don't commit changes after executing SQL queries? A) The changes are automatically committed. B) The changes are lost and not saved to the database. C) The database connection is closed. D) The cursor becomes unresponsive. Show Answer Correct Answer: B) The changes are lost and not saved to the database. ← PreviousNext →Related QuizzesScience QuizzesClass 12 QuizzesClass 12 Computer Science Chapter 2 Advanced Python Programming Quiz 1Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 3Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 4Class 12 Computer Science Chapter 1 Data Structures Using Python QuizClass 12 Computer Science Chapter 3 Database Management Systems QuizClass 12 Computer Science Chapter 4 Structured Query Language (Sql) QuizClass 12 Computer Science Chapter 5 Networking And Cyber Security QuizClass 12 Computer Science Chapter 6 Boolean Algebra And Logic Gates Quiz 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books