This quiz works best with JavaScript enabled. Home > Cbse > Class 12 > Science > Computer Science > Class 12 Computer Science Chapter 2 Advanced Python Programming – Quiz 4 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 4 (34 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Which method would you use to add an item to the end of a list named 'items'? A) Items.append(item). B) Items.push(item). C) List.add(items, item). D) Items.add(item). Show Answer Correct Answer: A) Items.append(item). 2. Config() in Python Tkinter are used to ..... A) Destroy the widget. B) Place the widget. C) Configure the widget. D) Change property of the widget. Show Answer Correct Answer: D) Change property of the widget. 3. Which of the following is a valid way to create a comment in Python? A) < This is a comment $\rightarrow$. B) // This is a comment. C) # This is a comment. D) /* This is a comment */. Show Answer Correct Answer: C) # This is a comment. 4. Why do we use variables in programming? A) Edit data. B) Integer. C) Store data. D) To look good. Show Answer Correct Answer: C) Store data. 5. Colors = ("red", "green", "burnt sienna", "blue")print("yellow" in colors)What is the result of the yellow in colors expression? A) False. B) True. C) ValueError:'yellow' is not in list. D) 4. Show Answer Correct Answer: A) False. 6. How can you access elements in a list in Python? A) My list.index. B) My list{index}. C) My list(index). D) My list[index]. Show Answer Correct Answer: D) My list[index]. 7. What is the purpose of using 'break' in a loop in Python? A) The 'break' statement is used to terminate the loop and transfer the execution to the statement immediately following the loop. B) The 'break' statement is used to skip the current iteration and continue with the next iteration of the loop. C) The 'break' statement is used to print a specific value to the console. D) The 'break' statement is used to create a new variable in Python. Show Answer Correct Answer: A) The 'break' statement is used to terminate the loop and transfer the execution to the statement immediately following the loop. 8. What is the purpose of using 'elif' in Python? A) The 'elif' statement is used to check for multiple conditions after the 'if' statement and before the 'else' statement. B) The 'elif' statement is used to end the program if the 'if' condition is not met. C) The 'elif' statement is used to create a new variable in Python. D) The 'elif' statement is used to print a specific value to the console. Show Answer Correct Answer: A) The 'elif' statement is used to check for multiple conditions after the 'if' statement and before the 'else' statement. 9. Which of the following is the correct output of the call to below line of code?print(list("hello")) A) ['h', 'e', 'l', 'l', 'o']. B) None of these. C) [h, e, l, l, o]. D) ['h' 'e' 'l' 'l' 'o']. Show Answer Correct Answer: A) ['h', 'e', 'l', 'l', 'o']. 10. What is the correct way to create a function in Python? A) Function myfunction():. B) Def myFunction():. C) Create myFunction():. D) None of the above. Show Answer Correct Answer: B) Def myFunction():. 11. Select the correct statement to install sql connector library A) Pip install mysql. B) Pip install mysql.connect. C) Pip install mysql-connector. D) Pip install mysql-connect-python. Show Answer Correct Answer: D) Pip install mysql-connect-python. 12. What are the advantages of python? A) Free and open source. B) Can do the work for you. C) Easy. D) None of the above. Show Answer Correct Answer: A) Free and open source. 13. Colors = ["red", "green", "burnt sienna", "blue"]print(colors[2])What is the output of the above python code? A) It causes a run-time error. B) 'blue'. C) 'burnt sienna'. D) 'green'. Show Answer Correct Answer: C) 'burnt sienna'. 14. How many times will a 'for' loop iterate if the range is specified as range(5)? A) 5. B) 3. C) 7. D) 10. Show Answer Correct Answer: A) 5. 15. List, tuple, and range are the ..... of Data Types. A) Sequence Types. B) Binary Types. C) Boolean Types. D) None of the mentioned above. Show Answer Correct Answer: A) Sequence Types. 16. Which symbol is used for single-line comments in Python? A) //. B) /* */. C) D) #. Show Answer Correct Answer: D) #. 17. What is the output of the following code:t=("CSE", "GEC", 34, 55.5)t[3]=123print(t) A) ("CSE", "GEC", 34, 123). B) Blank Output. C) ("CSE", "GEC", 123, 55.5). D) Error. Show Answer Correct Answer: D) Error. 18. Which of the following is a correct way to call a function named 'my ..... function'? A) Execute my function(). B) Call my function(). C) My function[]. D) My function(). Show Answer Correct Answer: D) My function(). 19. What is the meaning of the following comparison operator?a >= b A) Less than or equal to. B) Greater than or equal to. C) Not equal to. D) Equal to. Show Answer Correct Answer: B) Greater than or equal to. 20. The elements of a tuple are enclosed by ..... A) Square brackets. B) Curley brace. C) Parenthesis. D) Array bracket. Show Answer Correct Answer: C) Parenthesis. 21. Who began working on Python in the late 1980s? A) Guido van Rossum. B) Bjarne Stroustrup. C) Dennis Ritchie. D) James Gosling. Show Answer Correct Answer: A) Guido van Rossum. 22. What will be the output?print (type(5 // 2)) A) 2.5. B) Float. C) 2. D) Int. Show Answer Correct Answer: D) Int. 23. The ..... function is used to create Tuples from a list. A) List(). B) Tuple. C) Set(). D) Tuple( ). Show Answer Correct Answer: D) Tuple( ). 24. Creating line belongs to ..... category. A) GUI. B) Scripting. C) CGI. D) Canvas. Show Answer Correct Answer: D) Canvas. 25. Which is correct line to import pandas A) Import Pandas as pd. B) Import panda as pd. C) Import pandas as pd. D) None of the above. Show Answer Correct Answer: C) Import pandas as pd. 26. He is a Dutch Programmer known as the creator of Python? A) Guido van Rossum. B) Rasmus Lerdorf. C) James Gosling. D) Niklaus Wirth. Show Answer Correct Answer: A) Guido van Rossum. 27. Which arithmetic operators cannot be used with strings in Python? A) *. B) -. C) +. D) All of the mentioned. Show Answer Correct Answer: B) -. 28. What will be the output of this string operation s[2:5], if s="hello world" - A) Llo. B) Llow. C) Lo. D) Ell. Show Answer Correct Answer: A) Llo. 29. Which method can be used to remove any whitespace from both the beginning and the end of a string? A) Strip(). B) Len(). C) Trim(). D) Ptrim(). Show Answer Correct Answer: A) Strip(). 30. Which command will correctly ask the user for their age? A) Age = input("How old are you?"). B) How old are you = input(). C) Age = input(How old are you?). D) Input("How old are you?") = age. Show Answer Correct Answer: A) Age = input("How old are you?"). 31. What will be the output of the following Python code? 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 50Changed local x to 2x is now 50. B) X is 50Changed local x to 2x is now 2. C) X is 50Changed local x to 2x is now 100. D) None of the mentioned. Show Answer Correct Answer: A) X is 50Changed local x to 2x is now 50. 32. WHICH ONE OF THE FOLLOWING ARE USED RELATION BETWEEN TWO OR MORE VARIABLES? A) Arithmetic. B) Relational. C) Logical. D) None of the above. Show Answer Correct Answer: B) Relational. 33. What is the output of the following code snippet:'x = 5if x > 3:print('x is greater than 3')'? A) X is not defined. B) X is less than 3. C) X is equal to 3. D) X is greater than 3. Show Answer Correct Answer: D) X is greater than 3. 34. You want to sampling 10 from 100 patients (One-by-One). Which one does NOT necessary in your code? A) Set. B) For loop. C) While loop. D) Conditional Statement. Show Answer Correct Answer: B) For loop. ← PreviousRelated QuizzesScience QuizzesClass 12 QuizzesClass 12 Computer Science Chapter 2 Advanced Python Programming Quiz 1Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 2Class 12 Computer Science Chapter 2 Advanced Python Programming Quiz 3Class 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