21.03.plus Two Cs Review of Python QP Best
21.03.plus Two Cs Review of Python QP Best
BASICS
Which of the following is an immutable data type?
a) List
b) Dictionary
c) Tuple
d) Set
List (❌ Mutable): Lists can be modified after creation (elements can
be added, removed, or changed).
a) True b) 0x2B
c) -2.5E-3 d) YUV
(a) True ✅
This is a Boolean literal in Python.
True and False are the only Boolean literals.
(b) 0x2B ✅
This is a hexadecimal integer literal (base 16).
0x prefix denotes hexadecimal notation.
0x2B = (2 × 16 + 11) = 43 in decimal.
(c) -2.5E-3 ✅
This is a floating-point literal in scientific notation.
-2.5E-3 means −2.5×10−3=−0.0025−2.5×10−3=−0.0025, which is valid.
a) print(S[4:8]) b) print(S[-2:3:-1])
c) print(S[-2:-6]) d) print(S[7:-5:-1])
Which of the following statement(s) will not create dictionary D?
a) Statement 1 b) Statement 2
c) Statement 3 d) Statement 4
What will be the output of the following code?
L = [2, 4, '2', 2.0, [2, 20], ‘RT5']
print(L.count(2))
a) 1 b) 2
c) 3 d) 4
State True or False:
“Mutable data types in python allows changes at the same memory
location”
State True or False:
“Variable declaration is implicit in Python.”
Which of the following is the correct output for the execution of the
following Python statement?
print(5 + 3 ** 2 /2)
(A) 32 (B) 8.0
(C) 9.5 (D) 32.0
Select the correct output of the code:
a = "Good bye 2022. Welcome 2023"
a = a.split('0')
b = a[1] + ". " + a[0] + ". " + a[2]
print (b)
(a) 22. Welcome 2. Good bye 2. 23
(b) Good bye 2. 2322. Welcome 2.
(c) 22. Welcome 2. 232. Good bye
(d) 22. Good bye 2. 23 Welcome 2.
Given the following dictionaries
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
a) >>>a%b%c+1
b) >>>a%b%c+1.0
c) >>>a%b%c
d) a%b%c-1
The ___________ statement is an empty statement in Python.
Which of the following is not a keyword?
(a) eval (b) assert (c) nonlocal (d) pass
What will be the output for the following Python statements?
D= {“Amit”:90, “Reshma”:96, “Suhail”:92, “John”:95}
print(“John” in D, 90 in D, sep= “#”)
(a) True#False
(b)True#True
(c) False#True
(d) False#False
What will the following Python statement evaluate to?
print (5 + 3 ** 2 / 2)
(a) 32
(b) 8.0
(c) 9.5
(d) 32.0
Identify the errors in the following code:
MyTuple1=(1, 2, 3) #Statement1
MyTuple2=(4) #Statement2
MyTuple1.append(4) #Statement3
print(MyTuple1, MyTuple2) #Statement4
(a) Statement 1
(b) Statement 2
(c) Statement 3
(d) Statement 2 &3
State whether True or False: Variable names can begin with the _
symbol.
Identify which of the following is an invalid data type in Python:
2. Sequence Types
5. Boolean Type
a) True
b) False
c) None
d) NULL
Select the correct output of the following code:
>>>str1 = ‘India is a Great Country’
>>>str1.split(‘a’)
(a) [‘India’,’is’,’a’,’Great’,’Country’]
b) [‘India’, ’is’, ’Great’, ’Country’]
c) [‘Indi’, ’is’, ’Gre’, ’t Country’]
d) [‘Indi’, ’is’, ’Gre’, ’t’, ‘Country’
Which of the following will be the output of the code:
mySubject = “Computer Science”
print(mySubject[:3] + mySubject[3:])
a) Com
b) puter Science
c) Computer Science
d) Science Computer
Find the output of following code :
p = 10
q = 20
p *= q // 3
p = q ** 2
q += p
print(p, q)
Which statement will give the output as : True from the following :
a) >>>not -5
b) >>>not 5
c) >>>not 0
d) >>>not(5-1)
The input() function always returns a value of ……………..type.
a) Integer
b) float
c) string
d) Complex
To include non-graphic characters in python, which of the following is
used?
a. Special Literals
b. Boolean Literals
c. Escape Character Sequence
d. Special Literal – None
Which of the following operation is supported in python with respect
to tuple t?
a) t[1]=33
b) t.append(33)
c) t=t+t
d) t.sum()
Which of the following is not a valid identifier in Python?
a)Empuran b) _1st c) Hello_Dady d) Maya nadhi
What will be the output of the following statement ?
print(6+5/4**2//5+8)
(A) –14.0
(B) 14.0
(C) 14
(D) –14
Select the correct output of the code :
S = "text#next"
print(S.strip("t"))
(A) ext#nex
(B) ex#nex
(C) text#nex
(D) ext#next
What are mutable and immutable data types? Give examples.
continue: Skips the current iteration and continues with the next one.
Rewrite the following code in python after removing all syntax error(s).
Underline each correction done in the code.
250 = Number
WHILE Number<=1000:
if Number=>750:
print(Number)
Number=Number+100
else
print(Number*2)
Number=Number+50