Class 12 Computer Science Chapter 1 MCQs | Python Revision Tour & Functions

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
1Which of the following is NOT a valid variable name in Python?
a) my_variable
b) 123variable
c) variable123
d) _variable
1
2Which 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
3What will be the output of the following code?
numbers = [1, 2, 3, 4, 5]
total = 0
for num in numbers:
total += num
print(total)

a) 15
b) 10
c) 5
d) 0
1
4What will be the output of the following code?
numbers = [1, 2, 3, 4, 5]
for i in range(len(numbers)):
numbers[i] *= 2
print(numbers)

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
5What will be the output of the following code?
numbers = [1, 2, 3, 4, 5]
total = 0
for num in numbers:
if num % 2 == 0:
continue
total += num
print(total)

a) 9
b) 6
c) 5
d) 0
1
6What will be the output of the following code?
word = "Python"
reversed_word = ""
for char in word:
reversed_word = char + reversed_word
print(reversed_word)

a) Python
b) nohtyP
c) Py
d) ythoP
1
7What will be the output of the following code?
number = 10
while number > 0:
print(number)
number //= 2

a) 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
8Which 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
9Which 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
10Which 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
11What is the output of the following code?
my_list = [1, 2, 3, 4, 5]
new_list = my_list[::-1]
my_list[0] = 10
print(new_list)

A) [1, 2, 3, 4, 5]
B) [5, 4, 3, 2, 1]
C) [5, 4, 3]
D) [10, 2, 3, 4, 5]
1
12What is the output of the following code?
my_list = [1, 2, 3, 4, 5]
new_list = my_list.copy()
my_list.append(6)
print(new_list)

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
13Which 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
14What is the output of the following code?
str1 = "Hello World"
str2 = str1.replace("Hello", "Goodbye")
print(str1)

A) “Hello World”
B) “Goodbye World”
C) “Hello Goodbye”
D) Error: Strings are immutable and cannot be modified.
1
15What will be the output of the following code?
str1 = "Hello World"
result = str1.find("W")
print(result)

A) 6
B) 7
C) -1
D) Error: Strings do not have a `find()` method.
1
16What will be the output of the following code?
my_dict = {"apple": 3, "banana": 2, "cherry": 5}
sorted_dict = sorted(my_dict)
print(sorted_dict)

A) [“apple”, “banana”, “cherry”]
B) [“cherry”, “banana”, “apple”]
C) [(“apple”, 3), (“banana”, 2), (“cherry”, 5)]
D) Error: Dictionaries cannot be sorted.
1
17What is the output of the following code?
my_dict = {"apple": 3, "banana": 2, "cherry": 5}
keys = my_dict.keys()
print(keys)

A) [“apple”, “banana”, “cherry”]
B) [“apple”]
C) [“banana”]
D) dict_keys([“apple”, “banana”, “cherry”])
1
18What 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
19What does the following code snippet do?
my_string = "Hello, World!"
new_string = my_string.replace("Hello", "Hi")
print(new_string)

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
20What is the data type of the result after executing the following code?
x = "Hello"
y = 3
result = x * y

a) str
b) int
c) bool
d) None
1

Leave a Reply

Your email address will not be published. Required fields are marked *