This quiz works best with JavaScript enabled. Home > Cbse > Class 12 > Science > Computer Science > Class 12 Computer Science Chapter 2 Advanced Python Programming – Quiz 1 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 1 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. The method to install tkinter in system is ..... A) Pip install python. B) Tkinter install. C) Tkinter pip install. D) Pip install tkinter. Show Answer Correct Answer: D) Pip install tkinter. 2. Explain the concept of 'nested loops' in Python. A) Nested loops in Python involve one loop inside another loop, allowing for more complex iteration patterns. B) Nested loops in Python involve loops that are not related to each other. C) Nested loops in Python involve loops that run sequentially. D) Nested loops in Python involve loops that cannot be used together. Show Answer Correct Answer: A) Nested loops in Python involve one loop inside another loop, allowing for more complex iteration patterns. 3. What is the difference between a while loop and a for loop in Python? A) While loop is for beginners, for loop is for advanced programmers. B) The main difference is in their usage and the way they control the flow of the program. C) While loop is used for odd numbers, for loop is used for even numbers. D) The difference is in the color of the text they use. Show Answer Correct Answer: B) The main difference is in their usage and the way they control the flow of the program. 4. Which of the following declarations is incorrect? A) X = 2. B) X = 3. C) Xyz = 5. D) None of these. Show Answer Correct Answer: D) None of these. 5. Mandatory arguments required to connect any database from pyton A) User name, password. B) User name, password, host name, database name. C) User name, password, host name. D) Username, password, hostname, port, database name. Show Answer Correct Answer: C) User name, password, host name. 6. It is the process of joining two or more strings. A) Integration. B) Concatenation. C) Differentiation. D) Addition. Show Answer Correct Answer: B) Concatenation. 7. Which command will display the text 'Hello world!' on the screen? A) Print = "Hello world!". B) Print(Hello world!). C) Print("Hello world!"). D) Print "Hello world!". Show Answer Correct Answer: C) Print("Hello world!"). 8. What will be the output of the following Python code?a={1:"A", 2:"B", 3:"C"}a.items() A) Dict items([('A'), ('B'), ('C')]). B) Items(). C) Dict items([(1, 2, 3)]). D) Dict items([(1, 'A'), (2, 'B'), (3, 'C')]). Show Answer Correct Answer: D) Dict items([(1, 'A'), (2, 'B'), (3, 'C')]). 9. What is the output of print(type("Hello")) in Python? A) . B) . C) . D) . Show Answer Correct Answer: D) . 10. What symbol is used to denote "not equal" ? A) @=. B) !=. C) ?=. D) *=. Show Answer Correct Answer: B) !=. 11. What is the output of the following codex = 6 y = 2print(x ** y) print(x // y) A) 66 3. B) 36 0. C) 66 0. D) 36 3. Show Answer Correct Answer: D) 36 3. 12. Determine the output of the below Python code fragment?var1 = Truevar2 = Falsevar3 = Falseif var1 or var2 and var3:print("True")else:print("False") A) False. B) None of these. C) Runtime error. D) True. Show Answer Correct Answer: D) True. 13. Select the correct statement in python to check SQL connectivity status. A) If con.is connected():. B) If con.is connected. C) If con is.connected():. D) If con isconnected(). Show Answer Correct Answer: A) If con.is connected():. 14. Explain the concept of functions in Python. A) Functions in Python cannot take any input arguments. B) Functions in Python always return a boolean value. C) Functions in Python are used for decorative purposes only. D) Functions in Python are blocks of code that only run when they are called. They can take input arguments, perform some operations, and return a result. Functions help in organizing code, making it reusable, and easier to understand. Show Answer Correct Answer: D) Functions in Python are blocks of code that only run when they are called. They can take input arguments, perform some operations, and return a result. Functions help in organizing code, making it reusable, and easier to understand. 15. Which data type is the best to store possible outcome of tossing a dice? A) Tuple. B) List. C) Dictionary. D) None of the above. Show Answer Correct Answer: A) Tuple. 16. Which built-in function returns the absolute value? A) Abs(). B) Fabs(). C) Absolute(). D) All(). Show Answer Correct Answer: A) Abs(). 17. Which of the following is not used as loop in Python? A) For loop. B) While loop. C) Do-while loop. D) None of the above. Show Answer Correct Answer: C) Do-while loop. 18. What is the purpose of the interactive mode in Python? A) To write long scripts. B) To test and debug code snippets. C) To compile programs. D) To create databases. Show Answer Correct Answer: B) To test and debug code snippets. 19. The acronym csv is short for A) Comma Separate Values. B) Comma Separated Values. C) Comma Special Values. D) Case Separated Values. Show Answer Correct Answer: B) Comma Separated Values. 20. Which keyword is used to create an alias while importing a module in Python? A) With. B) Alias. C) As. D) Rename. Show Answer Correct Answer: C) As. 21. In Python3, which functions are used to accept input from the user A) Rawinput(). B) Input(). C) Raw input(). D) String(). Show Answer Correct Answer: B) Input(). 22. The ..... provides pictorial representation of given problem. A) Algorithm. B) Flowchart. C) Pseudocode. D) All of these. Show Answer Correct Answer: B) Flowchart. 23. Data Frame contains? A) Data of same Types. B) Data of Different Types. C) All the above. D) None of the above. Show Answer Correct Answer: A) Data of same Types. 24. Which of the follwoing looping statement(s) is/are invalid in Python A) Do-while. B) While-else. C) For-else. D) For. E) While. Show Answer Correct Answer: A) Do-while. 25. What is the difference between '==' and 'is'? A) The '==' operator checks for value equality, while 'is' checks for identity. B) Both '==' and 'is' check for value equality. C) '==' checks for identity, while 'is' checks for value equality. D) '==' is used for comparing strings, while 'is' is used for comparing numbers. Show Answer Correct Answer: A) The '==' operator checks for value equality, while 'is' checks for identity. 26. How do you define a function that takes two parameters, 'fname' and 'lname'? A) My function(fname, lname). B) Def my function(fname, lname). C) Def my function:fname, lname. D) Function my function(fname, lname). Show Answer Correct Answer: B) Def my function(fname, lname). 27. In Python, what does the 'return' statement do in a function? A) Exits the function. B) Deletes the function. C) Calls another function. D) Returns a value. Show Answer Correct Answer: D) Returns a value. 28. S1 = pd.series([11, 12, 13, 14])s2 = pd.series([11, 12, 13, 14], index=[1, 2, 3, 4])print(s1+s2) gives? A) 0 221 242 263 28. B) 0 111 122 133 140 111 122 133 14. C) Error. D) None of the above. Show Answer Correct Answer: C) Error. 29. What does 'len("hello")' return? A) 4. B) Hello. C) 5. D) Hello!. Show Answer Correct Answer: C) 5. 30. Which of the following is the output of the below Python code?var1 = lambda var:var * 2ret = lambda var:var * 3result = 2result = var1(result)result = ret(result)result = var1(result)print(result) A) 36. B) 12. C) 7. D) 24. E) 48. Show Answer Correct Answer: D) 24. 31. Which collection is ordered, changeable, and allows duplicate members? A) TUPLE. B) DICTIONARY. C) LIST. D) SET. Show Answer Correct Answer: C) LIST. 32. How do you display output in Python using the print() function? A) Print[ "values" ]. B) Print= data. C) Call the print() function followed by the content to display within parentheses. D) Let values be printed. Show Answer Correct Answer: C) Call the print() function followed by the content to display within parentheses. 33. Why is it important to follow proper naming conventions for variables and functions in Python? A) Naming variables and functions randomly improves code quality. B) Proper naming conventions lead to slower code execution. C) Following naming conventions is not important in Python. D) It is important to follow proper naming conventions for variables and functions in Python to ensure code readability, maintainability, and adherence to PEP 8 guidelines. Show Answer Correct Answer: D) It is important to follow proper naming conventions for variables and functions in Python to ensure code readability, maintainability, and adherence to PEP 8 guidelines. 34. What is the primary use of the print command in Python? A) To display output to the console. B) To compile the code. C) To create a graphical user interface. D) To accept user input. Show Answer Correct Answer: A) To display output to the console. 35. What happens to the text entered by the user when using the input() function in Python? A) It is returned as a string. B) It is ignored by the program. C) It is compiled into bytecode. D) It is displayed as output. Show Answer Correct Answer: A) It is returned as a string. 36. Patients visit hospital everyday. You want to count for the "new patients" for each day. Which one is not necessary? A) Set. B) For loop. C) Set difference. D) While loop. Show Answer Correct Answer: D) While loop. 37. Which of the following is the output of the instructions given below?mylist=[1, 5, 9, int('0')]print(sum(mylist)) A) 1. B) 15. C) 5. D) 16. Show Answer Correct Answer: B) 15. 38. Find the output of the given Python program?print(list("abcd" .split(" ))) A) ['a', '', 'b', '', 'c', '*', 'd']. B) ['abcd']. C) ['a', 'b', 'c', 'd']. D) ['abc*d']. Show Answer Correct Answer: C) ['a', 'b', 'c', 'd']. 39. What is the purpose of the 'else' statement in Python conditional statements? A) To execute a block of code when the condition in the 'if' statement is false. B) To repeat the 'if' condition. C) To skip the 'if' condition. D) To define a new condition. Show Answer Correct Answer: A) To execute a block of code when the condition in the 'if' statement is false. 40. Method used to bring data from a csv file into a DataFrame A) Readcsv(). B) Read-csv(). C) Read table(). D) Read csv(). Show Answer Correct Answer: D) Read csv(). 41. Which device is required for the Internet connection? A) Modem. B) CD Drive. C) NIC Card. D) Repeater. Show Answer Correct Answer: A) Modem. 42. What is the output of the following Python code snippet? print(5 + 3 * 2) A) 10. B) 13. C) 16. D) 11. Show Answer Correct Answer: D) 11. 43. What will be the output of the following Python code snippet?not(10<20) and not(10>30) A) False. B) No output. C) Error. D) True. Show Answer Correct Answer: A) False. 44. The instructor wants to know the age of the persons with rank3. Help her to identify the correct set of statement/s from the given options: A) Print(df.loc['rank3']). B) Print(df.iloc['rank3']). C) Print(df.loc['rank3']). D) Print(df.loc('rank3')). Show Answer Correct Answer: A) Print(df.loc['rank3']). 45. Which among these are the special operators in python A) Bitwise operator. B) Logical Operator. C) Membership operator. D) Relational operator. Show Answer Correct Answer: C) Membership operator. 46. Select the reserved keyword in python- A) Else. B) Raise. C) Import. D) All of them. Show Answer Correct Answer: D) All of them. 47. How do you create a for loop in Python? A) For item from my list:. B) For item in my list:. C) For i in range(my list):. D) For item in my list(){}. Show Answer Correct Answer: B) For item in my list:. 48. SQL command for list databases. A) Show all;. B) Show all databases;. C) Show databases;. D) Show database;. Show Answer Correct Answer: C) Show databases;. 49. The symbol used for giving Comments in Python is A) &. B) $. C) !. D) #. Show Answer Correct Answer: D) #. 50. What is the purpose of setting the path in Windows for Python? A) To add Python to the system path. B) To create a new Python version. C) To change the Python version. D) To uninstall Python. Show Answer Correct Answer: A) To add Python to the system path. 51. How does Python interact with the hardware of a computer? A) Directly interacts with the hardware. B) Uses an interpreter to translate high-level code into machine code. C) Uses a compiler to translate high-level code into machine code. D) Does not interact with the hardware at all. Show Answer Correct Answer: B) Uses an interpreter to translate high-level code into machine code. 52. The ..... will be useful to access all the elements in a nested tuple. A) For loop. B) If elif else. C) Switch case. D) If condition. Show Answer Correct Answer: A) For loop. 53. WHAT ARE THE SEMANTIC RULES OF A LANGUAGE CALLED? A) Syntax. B) Identifies. C) Variables. D) None of the above. Show Answer Correct Answer: B) Identifies. 54. What is one of the reasons why programmers use the Python programming language? A) Python's syntax is complex and hard to read. B) Python's simplicity decelerates the learning curve. C) Python is highly versatile and used in various fields. D) Python has a weak community with limited resources. Show Answer Correct Answer: C) Python is highly versatile and used in various fields. 55. In a nested tuple, each tuple is considered as an ..... A) Element. B) Variable. C) Parameter. D) None of these. Show Answer Correct Answer: A) Element. 56. Which of the following statement/s will give 2 rows from bottom of the dataframe? A) Print(df.tail(4)). B) Print(df.tail()). C) Print(df.tail(2)). D) Print(df.tail[2]). Show Answer Correct Answer: C) Print(df.tail(2)). 57. What is the correct way to handle exceptions in Python? A) Try except. B) Error catch. C) Do while. D) Try catch. Show Answer Correct Answer: A) Try except. 58. What is the purpose of loops in Python? A) The purpose of loops in Python is to print statements only once. B) Loops in Python are used for sorting data. C) The purpose of loops in Python is to iterate over sequences or execute a block of code repeatedly. D) Loops in Python are designed to skip over code blocks. Show Answer Correct Answer: C) The purpose of loops in Python is to iterate over sequences or execute a block of code repeatedly. 59. What is the output of the following Python code snippet?string = "Hello, World!"print(string[3:7]) A) "lo, ''. B) "lo, W". C) "Hello". D) "lo, World". Show Answer Correct Answer: A) "lo, ''. 60. Which of these collections defines a SET? A) {"apple", "banana", "cherry"}. B) {"name": "apple", "color": "green"}. C) ["apple", "banana", "cherry"]. D) ("apple", "banana", "cherry"). Show Answer Correct Answer: A) {"apple", "banana", "cherry"}. Next →Related QuizzesScience QuizzesClass 12 QuizzesClass 12 Computer Science Chapter 2 Advanced Python Programming Quiz 2Class 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