0% found this document useful (0 votes)
3 views5 pages

Python MCQ Objective

This document is a sample objective test containing multiple-choice questions (MCQs) focused on Python programming concepts. It covers topics such as Python modes, identifiers, escape sequences, operators, and error handling. The test includes 40 questions with options for each, aimed at assessing knowledge of Python syntax and functionality.

Uploaded by

sanjhbati.ray
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Python MCQ Objective

This document is a sample objective test containing multiple-choice questions (MCQs) focused on Python programming concepts. It covers topics such as Python modes, identifiers, escape sequences, operators, and error handling. The test includes 40 questions with options for each, aimed at assessing knowledge of Python syntax and functionality.

Uploaded by

sanjhbati.ray
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SAMPLE OBJECTIVE TEST

PYTHON MCQ(PRACTICE SHEET)

Q1. The _______________ mode of Python gives instant result of typed statement.
(a) Interactive mode
(b) Script mode
(c) Combination of interactive & Script mode
(d) All of these

Q2. Python uses a/an ________________ to convert source code to object code.

(a) interpreter (b) Compiler


(c) Combination of interpreter & compiler (d) Special virtual Engine

Q3. Which of the following is valid identifier?


(a) my name (b) _myname (c) 2 my name (d) my – name

Q4. Escape sequences are treated as ________


(a) strings (b) characters (c) integers (d) None of these

Q5. To print a line of text without ending it with a newline_______ argument is used with print ( )
(a) sep (b) new line (c) end (d) next

Q6. The input ( ) returns the value as _________ type.


(a) integer (b) string (c) floating point (d) none of these
Q7. What is the value of the expression 15 + 3 ** 4 * 7
(a) 831 (b) 734832 (c) 582 (d) None of these
Q8. What will be the output of the following code?
a = 99.8
b=2
print (a // b)
(a) 49.9 (b) 49.0
(c) 49 (d) compilation Error

Q9. In the python statement


x = y + 10/20
y + 10/20 is ____________________
(a) Expression (b) Operands (c) Operators (d) Equation

Q10. Find out which assignment statement(s) will produce an error from the
following statement
(i) y = Oh3f
(ii) V = 87.EO2
(iii) This = „334‟
(iv) if = 62
(a) (i) (b) (i) & (iv) (c) (iii) (d) none of these

Q11. The operator used to check if both the operands reference the same object
memory, is the _______ operator.
(a) in (b) is (c) id (d) ==
Q12. In the python statement
x=a+5–b
a and b are ___________
(a) Operands (b) Expression (c) Operators (d) Equation

Q13. The concept of assigning different values to a variable at different lines in same
program is called ___________.
(a) Dynamic Typing (b) Static Typing (c) Mutability (d)
immutability

Q14. What is the value of x?


x = int (13.25 + 4/2)
(a) 17 (b) 14 (c) 15 (d) 23

Q15. Which type of error Occurs when you execute the following code
fragment?

>>> int (‟22.43‟)


(a) Syntax error (b) Name error (c) Value erro r (d) Type error

Q16. Which of the following is an augmented assignment operator?


(a) += (b) = = (c) ! = (d) +
Q17. What will be the output of the following python code?
for (i in range (2.0)):
print (i)
(a) 0.0 1.0 (b) 01 (c) error (d) none of these

Q18. What will be the output of the following python code?


i=1
while True:
if i % 2 == 0 :
break
print (i)
i+=2
(a) 1 (b) 1 2 (c) 1 2 3 4 5 6 (d) 1 3 5 7 9 11 ……

Q19. What will be the output of the following code:-


for i in range (10):
if i == 5 :
break
else:
print (i)
else:
print (“Here”)

Q20. What will be the output of the following python code?


string = “my name is x”
for i in string:
print (i, end = “, “ )
(a) m, y, , n , a, m, e, , i, s, x,
(b) m, y,, n, a , m, e,, i, s, ,x
(c) my, name, is, x,
(d) none of these
Q21. An empty/null statement in python is ______________
(a) go (b) pass (c) over (d) ;

Q22. State the correct output of the following python statements: -


a=1
r=2
for b in range (–5, –1):
a+ = (–1) ** r * b
print (a)
(a) 15 (b) –13 (c) –14 (d) None of these

Q23. The order of statement execution in the form of top to

Q24. The __________statement can terminate a loop immediately and the control passes
over to the statement following the loop.
(a) break (b) continue (c) none of these (d) both of these
Q25. Function range (0, 5, 2) will yield on alterable sequence like
(a) [0, 2, 4] (b) [1, 3, 5] (c) [0, 1, 2, 5] (d) [0, 5, 2]

Q26. What is the output produced when this code executes?


a=0
for i in range (4, 8):
if i % 2 == 0:
a=a+i
print (a)
(a) 4 (b) 8 (c) 10 (d) 18

Q27. Which of the following functions will return the last three characters of a
string S

(a) S [3 : ] (b) S [ : 3] (c) S [–3:] (d) S [: – 3]

Q28. Which of the following function will return the string with every „P‟ replaced
with a „Z‟?

(a) find ( ) (b) index ( ) (c) replace ( ) (d) split ( )

Q29. What is the output of the following code?


a = “mission999”
b = “999”
print ([Link]( ), [Link]( ) )
(a) FalseTrue (b) FalseFalse (c) TrueFalse (d) TrueTrue
Q30. You have the following code segment:
a = “my”
b = “work”
print (a+b)
What will be the output of this code?
(a) my work (b) work (c) mywork (d) my

Q31. Which line of code produces an error


(a) “one” + “two” (b) 1 + 2 (c) “one” + “ 2 ” (d) „1‟
+2
Q32. Which of the following functions will return always a type of 3 elements?
(a) find( ) (b) index( ) (c) partition( ) (d) split( )
Q33. Choose the correct function to get the character from ASCII number
(a) ascii(number ) (b) char(number) (c) chr(number) (d) All of these
Q34. Which of the following function will raise on error if the given substring is not found
in the string?
(a) find( ) (b) index( ) (c) replace( ) (d) all of these
Q35. Which the following functions remove all leading and trailing spaces from a string?
(a) lstrip( ) (b) rstrip( ) (c) strip( ) (d) all of these
Q36. Select the correct output of the following string operations
str1 = “ Waha”
print ( str1[: 3] + „Bhyi‟ + str1[–3:])
(a) Wah Bhyi Wah (b) WahBhyiaha (c) WahBhyiWah (d) WahBhyiWaha

Q37. The CPU is also known as:


(a) The Brain (b) The processor
(c) The central processing unit (d) All of these

Q38. In a computer CU stands for


(a) Control Unit (b) Cache Unit
(c) Calculating Unit (d) Communication Unit

Q39. Operating System is an example of


(a) Application Software (b) System Software
(c) Utility Program (d) none of these
Q40. A disk fragmentor is an example of
(a) Application Software (b) System Software
(c) Package (d) none of these.

You might also like