MULTIPLE CHOICE QUESTIONS (MCQs)
CLASS 12 COMPUTER SCIENCE
UNIT-1: COMPUTATIONAL THINKING AND PROGRAMMING – 2
PYTHON REVISION TOUR & FUNCTIONS, MODULES AND LIBRARIES
Section A (20 × 1 = 20 Marks)
| Q. No. | Question | Marks |
|---|---|---|
| 1 | Which of the following is NOT a valid variable name in Python? a) my_variable b) 123variable c) variable123 d) _variable | 1 |
| 2 | Which of the following is a recommended practice when naming variables in Python? a) Using single letters or abbreviations for variable names to save space b) Starting variable names with an underscore (_) to indicate privacy c) Using descriptive names that convey the purpose or meaning of the variable d) Including special characters, such as @ or $, in variable names for uniqueness | 1 |
| 3 | What will be the output of the following code?numbers = [1, 2, 3, 4, 5]a) 15 b) 10 c) 5 d) 0 | 1 |
| 4 | What will be the output of the following code?numbers = [1, 2, 3, 4, 5]a) [1, 2, 3, 4, 5] b) [2, 4, 6, 8, 10] c) [1, 4, 9, 16, 25] d) [2, 3, 4, 5, 6] | 1 |
| 5 | What will be the output of the following code?numbers = [1, 2, 3, 4, 5]a) 9 b) 6 c) 5 d) 0 | 1 |
| 6 | What will be the output of the following code?word = "Python"a) Python b) nohtyP c) Py d) ythoP | 1 |
| 7 | What will be the output of the following code?number = 10a) 10 5 2 1 b) 10 8 6 4 2 c) 10 5 2 d) 10 9 8 7 6 5 4 3 2 1 | 1 |
| 8 | Which of the following options correctly checks if two lists are equal in Python? A) list1 == list2 B) list1 is list2 C) list1.equals(list2) D) list1.compare(list2) | 1 |
| 9 | Which of the following methods returns the index of the first occurrence of a specified value in a list? A) index() B) find() C) search() D) locate() | 1 |
| 10 | Which of the following options correctly merges two lists in Python? A) list1 + list2 B) list1.extend(list2) C) list1.append(list2) D) list1.merge(list2) | 1 |
| 11 | What is the output of the following code?my_list = [1, 2, 3, 4, 5]A) [1, 2, 3, 4, 5] B) [5, 4, 3, 2, 1] C) [5, 4, 3] D) [10, 2, 3, 4, 5] | 1 |
| 12 | What is the output of the following code?my_list = [1, 2, 3, 4, 5]A) [1, 2, 3, 4, 5] B) [1, 2, 3, 4, 5, 6] C) [1, 2, 3, 4, 5, [6]] D) [1, 2, 3, 4, 5, (6)] | 1 |
| 13 | Which of the following options correctly splits a string into a list of words in Python? A) str.split() B) str.split(‘,’) C) str.split(‘ ‘) D) All of the above | 1 |
| 14 | What is the output of the following code?str1 = "Hello World"A) “Hello World” B) “Goodbye World” C) “Hello Goodbye” D) Error: Strings are immutable and cannot be modified. | 1 |
| 15 | What will be the output of the following code?str1 = "Hello World"A) 6 B) 7 C) -1 D) Error: Strings do not have a `find()` method. | 1 |
| 16 | What will be the output of the following code?my_dict = {"apple": 3, "banana": 2, "cherry": 5}A) [“apple”, “banana”, “cherry”] B) [“cherry”, “banana”, “apple”] C) [(“apple”, 3), (“banana”, 2), (“cherry”, 5)] D) Error: Dictionaries cannot be sorted. | 1 |
| 17 | What is the output of the following code?my_dict = {"apple": 3, "banana": 2, "cherry": 5}A) [“apple”, “banana”, “cherry”] B) [“apple”] C) [“banana”] D) dict_keys([“apple”, “banana”, “cherry”]) | 1 |
| 18 | What does it mean for a Python object to be “immutable”? a) It cannot be modified or changed after it is created. b) It can only be accessed by a single thread at a time. c) It can be converted to a different data type using type casting. d) It can be modified but only within a limited range of values. | 1 |
| 19 | What does the following code snippet do?my_string = "Hello, World!"a) Replaces all occurrences of “Hello” with “Hi” in the string. b) Replaces the first occurrence of “Hello” with “Hi” in the string. c) Replaces all occurrences of “Hi” with “Hello” in the string. d) Replaces the first occurrence of “Hi” with “Hello” in the string. | 1 |
| 20 | What is the data type of the result after executing the following code?x = "Hello"a) str b) int c) bool d) None | 1 |
