Chapter 1 Python Revision Tour 1
MCQ
1. What is the current version of Python?
a. 3.9.0
b. 3.9.2
c. 3.9.4
d. 3.9.6
Answer: d
2. Who created Python?
a. Guido Von Rossum
b. Dennis Ritchie
c. James Gosling
d. Bjarne Stroustrup
Answer: a
3. Python is developed using which language?
a. C Programming
b. C++ Programming
c. Java Programming
d. None of above
Answer: a
4. Python is a specialized language which deals in:
a. Artificial Intelligence
b. Machine Learning
c. Deep Learning
d. All of above
Answer: d
5. Python’s first version was released in which year?
a. 1990
b. 1991
c. 1992
d. 1993
Answer: b
6. Which of these is not a valid identifier?
a. 1st
b. First
c. Position1
d. Rank1
Answer: a
7. Which of these is a valid identifier?
a. For
b. IF
c. Return
d. All of these.
Answer: d
8. What is the value of the following expression ?
2**3**2
a. 64
b. 256
c. 512
d. 12
Answer: c
9. Identify the valid arithmetic operator in Python from the following.
a. ?
b. <
c. **
d. and
Answer:c
10. Which of the following is not a keyword ?
a. eval
b. assert
c. nonlocal
d. pass
Answer: a
11. Which of these is not a core data type ?
a. List
b. Dictionary
c. Tuple
d. Class
Answer: d
13. Evaluate the expression given below if A = 16 and B = 15
A%B//A
a. 0.0
b. 0
c. 0.1
d. 1.0
Answer: b
14. Which among the following list of operators has the highest precedence ?
+, -, **, %, /, <<, >>, |
a. <<, >>
b. **
c. |
d. %
Answer: b
15. Which of the following expressions result in an error ?
a. float('12')
b. int('12')
c. float('12.5')
d. int('12.5')
Answer: d
16. Which character is used in Python to make a single line comment ?
a. /
b. //
c. #
d. !
Answer: c
17. Which of the following statements is correct regarding the Object-Oriented Programming
concept in
Python ?
a. Classes are real-world entities while objects are not real
b. Objects are real-world entities while classes are not real
c. Both objects and classes are real world entities
d. All of the above
Answer: b
18. How would you write xy in Python as expression ?
a. x^y
b. x**y
c. x*y
d. None of these
Answer: c
19. What is the output of the following code ?
x = 123
for i in x:
print(i)
a. 1 2 3
b. 123
c. Infinite loop
d. Error
Answer: d
20. What is the value of the following expression ?
3+3.00, 3**3.0
a. (6.0, 27.0)
b. (6.0, 9.00)
c. (6, 27)
d. [6.0, 27.0]
e. [6, 27]
Answer: a
22. Which of the following Pythons functions id used to iterate over a sequence of numbers by
specifying
a numeric end value as its argument ?
a. range()
b. len()
c. substring()
d. random()
Answer: a
23. How many keywords are there in Python ?
a. 33
b. 4
c. 32
d. 35
Answer: a
24. Python works in which type of typing ?
a. Dynamic
b. Static
c. Text
d. None of the above
Answer: a
25. What is the full form of ASCII ?
a. American Standard Code for Information Interchange
b. Asian Standard Code for Information Interchange
c. American Standard Code for Indian Interchange
d. None of the above
Answer: a
26. Which of the following is mutable ?
a. List
b. Dictionary
c. Tuple
d. Both a and b
Answer: d
27. What does the break statement do ?
a. Runs the loop infinitely
b. Does nothing
c. Terminates the loop
d. None of the above
Answer: c
28. Is Python case sensitive when dealing with identifiers ?
a. Yes
b. No
c. Machine dependant
d. None of the above
Answer: a
29. What is the maximum possible length of an identifier ?
a. 31
b. 63
c. 78
d. None of the above
Answer: d
30. ________ are additional readable information to clarify the statement in Python.
a. Comments
b. Expressions
c. Tokens
d. Flow of control
Answer: a
31. Which of the following literals has either True or False value ?
a. Special literals
b. Boolean literals
c. Numeric literals
d. String literals
Answer: b
32. What will be the value of x ?
x = int(13.25+4/2)
a. 15.0
b. 14
c. 15
d. None of the above
Answer: c
33. The token 'if' is a ______.
a. Keyword
b. Identifier
c. Literal
d. Punctuator
Answer: a
34. What will be the value of the following expression ?
(5>10) and (10<5) or (3<18) and (8<18)
a. False
b. True
c. Error
d. None of the above
Answer: b
35. A token is also called a _________.
a. Names
b. Atomic unit
c. Lexical unit
d. Literals
Answer: c
36. Name the smallest individual unit in a program.
a. Keyword
b. Token
c. Identifier
d. Literal
Answer: b
37. Which of the following is not a token ?
a. Comment
b. Identifier
c. Literal
d. Keyword
Answer: a
38. _________ is a word having a special meaning reserved by the programming language.
a. Identifier
b. Operator
c. Keyword
d. Boolean
Answer: c
39. _________ are the names given to different parts of a program
a. Tokens
b. Strings
c. Literals
d. Identifiers
Answer: d
40. Type casting is also known as -
a. Explicit Type Conversion
b. Implicit Type Conversion
c. Operand
d. Inverted
Answer: a
41. ________ statement abandons the current iteration of a loop.
a. break
b. continue
c. pass
d. None of the above
Answer: b
42. What will be the return value of the function calls given below ?
float('1e-003')
float('2e+003')
a. 3.00 and 300
b. 0.001 and 200
c. 0.001 and 2000.0
d. Error and 2003
Answer: c
43. Which of the following functions accepts only integers as arguments ?
a. ord()
b. min()
c. chr()
d. type()
Answer: c
44. Python files are saved with the extension _____.
a. .python
b. .pe
c. .py
d. .pi
Answer: c
45. Which of the following statements is correct for 'and' operator ?
a. Python evaluates the second argument only if the first one is False
b. Python evaluates the second argument only if the first one is True
c. Python evaluates True if any one of the argument is True
d. Python only evaluates False if any one argument is True
Answer: b
46. Which of the following is the correct statement ?
a. xyz = 10 100 1000
b. x y z = 10 100 1000
c. x, y, z = 10, 100, 1000
d. x y z = 10, 100, 1000
Answer: c
47. The octal literal and hexadecimal literals start with which of the following symbols respectively ?
a. O0 and X0
b. 0O and 0X
c. Oct0 and Hex0
d. 0o and 0x
Answer: d
48. The Error produced by the above code is:
a = None
print(a+1)
a. Syntax Error
b. Type Error
c. Value Error
d. Name Error
Answer: b
49. What will be the output of the following code ?
a=1
z = a+a-a*a/a//a%a**a
print(z)
a. 1
b. 1.0
c. 2.0
d. None of the above
Answer: c
50. What will be the value of the following expression ?
0.1+0.2 == 0.3
a. True
b. False
c. Machine dependant
d. Error
Answer: b
51. Which of the following is a valid Python if statement ?
a. if a>=2:
b. if (a>=2)
c. if (a=>22):
d. if a>=22
Answer: a
52. Which of the following is a valid for loop in Python ?
a. for (i = 0; i < n; i++)
b. for i in range(0, 5)
c. for i in range(0, 5):
d. for i in range(5)
Answer: c
53. What will be the output of the following code ?
x = "abcdef"
i = "i"
while i in x:
print(i, end="")
a. a b c d e f
b. abcdef
c. i i i i …
d. No output
Answer: d
54. Which of the following is/are compile time errors ?
a. Syntax error
b. Semantic error
c. Both a and b
d. None of these
Answer: c
55. Which of the following is incorrect regarding variables in Python?
A. Variable names in Python cannot start with number. However, it can contain number in any other
position of variable name.
B. Variable names can start with an underscore.
C. Data type of variable names should not be declared
D. None of the above
Answer : D
Explanation: All of the above options are correct regarding variables in Python.
56. Which of the following is a relational operator ?
a. /
b. ==
c. is
d. <<
Answer: b
57. Which character is used to go to a new line ?
a. \
b. \t
c. \oo
d. \n
Answer: d
58. What will be the output of the following code ?
a = 547
while a > 0:
a = a//10
print(a)
a. 547
b. 547 54 5
c. 54 5 0
d. No output
Answer: c
59. What will be the output of the following code ?
import math
print(math.floor(1.99999999999999999999))
a. 1
b. 2
c. 1.0
d. 2.0
Answer : b
60. How a>b>c will be interpreted by python?
A. a>b or b>c
B. a>b not b>c
C. a>b and b>c
D. a>b && b>c
Answer: c
61. Evaluate the following expression.
x % y // x, if x = 5, y = 4
A. 1.0
B. 0.0
C. 0
D. 1
Answer: c
62. Which of the following statements is true?
a. Python is an interpreted language.
b. Python is a high level programming language.
c. Python is an object-oriented language.
d. All of the above.
Correct answer- d
63,Which of the following is correct?
a. Comments are for programmers for better understanding of the program.
b. Python Interpreter ignores comment.
c. You can write multi-line comments in Python using triple quotes, either ''' or """.
d. All the above
Correct answer - d
64.Is it possible to check for more than one error in one except line?
a. Yes, if the exception types are enclosed in parentheses.
b. No, it is not possible.
c. Yes, if the exception types are enclosed in square brackets.
d. Yes, if the exception types are enclosed in curly braces.
Correct answer - a
65.Which of the following is not a keyword?
a. Open
b. lambda
c. is
d. except
Correct answer - open
66. All keywords available in Python are in
a. Uppercase
b. Lowercase
c. Both uppercase and lowercase
d. CamelCase
Correct answer - c
67.Is Python case sensitive when dealing with identifiers?
a. Yes
b. No
c. machine dependent
d. No specific rules for declaration of identifiers
Correct answer - a
68. Why are local variable names beginning with an underscore discouraged?
A. they confuse the interpreter
B. they are used to indicate a private variables of a class
C. they are used to indicate global variables
D. they slow down execution
Ans : B
Explanation: local variable names beginning with an underscore discouraged because they are used
to
indicate a private variables of a class. So, Option B is correct.
69.Which of the following is valid ?
a. _var = 'python'
b. __var = 'python'
c. _name_ = 'python'
d. All the above
Correct answer - d
70.How to swap two variables in one line ?
a. x = y
b. x ^= y ^= x ^= y
c. x, y = y, x
d. (x ^= y), (y ^= x), (x ^= y)
Correct answer - c
71.Which of the following is an invalid statement?
a. num = 1,000,000
b. x y z = 1 2 3
c. x,y,z = 1, 2, 3
d. x_y_z = 1,000,000
Correct answer - b
72..Output of print(f"Python {3 + .2}")
a. 3.2
b ) 3+.2
c ) Python 3.2
d) Shows Error
Correct answer - c
73.Which of the following statements assigns the value 100 to the variable x in Python:
a. let x = 100
b. x := 100
c. x ← 100
d. x = 100
Correct answer - d
74.Which of the following is not a complex number?
a. a = 2 + 3j
b. a = complex(2, 3)
c. a = 2 + 3l
d. a = 2 + 3J
Correct answer - c
75.Boolean type is a subtype of Integer data type in Python
a) True
b) False
Correct answer - a
76.What is the result of round(0.5) - round(-0.5)
a. 1.0
b. 2.0
c. 0.0
d. 0
Answer- d
77. What is used to define a block of code in Python?
A. Parenthesis
B. Indentation
C. Curly braces
D. None of the above
Answer : B
Explanation: Python uses indentation to define block of code. Indentations are simply Blank spaces
or
Tabs which is used as an indicator that indented code is the child part. As curlybraces are used in
C/C++/Java.. So, Option B is correct.
78.Which of the following will run without errors?
a) round(655.8)
b) round(902.898,8,10)
c) round()
d) round(763.12,2,2.1)
Answer: a
79.What is the value of the following expression?
float(22//3+3/3)
a) 8
b) 8.0
c) 8.3
d) 8.33
Answer: b
80.The expression 2**2**3 is evaluates as: (2**2)**3.
a) True
b) False
c)Error
d)None
Answer: b
81. Give the output of following with justification. [CBSE SQP 2015]
x=3
x+ = x-x
print x
Answer: 3
Working :
x=3
x = (x+ x-x ):x = 3 + 3 - 3 = 3
82.What will be the output of the following Python code?
x = "diya"
i = "a"
while i in x:
print(i, end = " ")
a) no output
b) None
c) Infinite loop(a a a…….)
d) a b c d e f
Answer: c
83. Which one of the following is a valid Python if statement :
A. if a>=2 :
B. if (a >= 2)
C. if (a => 22)
D. if a >= 22
Answer : A
Explanation: If statment always ended with colon (:). So, option A is correct.
84. What keyword would you use to add an alternative condition to an if statement?
A. else if
B. elseif
C. elif
D. None of the above
Answer: C
Explanation: elif is used to add an alternative condition to an if statement. So, option C is correct.
85. Can we write if/else into one line in python?
A. Yes
B. No
C. if/else not used in python
D. None of the above
Answer: A
Explanation: Yes, we can write if/else in one line. For eg i = 5 if a > 7 else 0. So, option A is correct.
86. In a Python program, a control structure:
A. Defines program-specific data structures
B. Directs the order of execution of the statements in the program
C. Dictates what happens before the program starts and after it terminates
D. None of the above
Answer : B
Explanation: Control structures determine which statements in the program will be executed and in
what
order, allowing for statements to be skipped over or executed repeatedly. So, option B is correct.
87. What will be output of this expression:
'p' + 'q' if '12'.isdigit() else 'r' + 's'
A. pq
B. rs
C. pqrs
D. pq12
Answer : A
Explanation: If condition is true so pq will be the output. So, option A is correct.
88. Which statement will check if a is equal to b?
A. if a = b:
B. if a == b:
C. if a === c:
D. if a == b
Answer : B
Explanation: if a == b: statement will check if a is equal to b. So, option B is correct.
89. Does python have switch case statement?
A. True
B. False
C. Python has switch statement but we can not use it.
D. None of the above
Answer : B
Explanation: Python does not have switch case statement. So, option B is correct.
90. Which of the following is not used as loop in Python?
A. for loop
B. while loop
C. do-while loop
D. None of the above
Answer : C
Explanation: do-while loop is not used as loop in Python.
91. What will be the output of the following program on execution?
a=0
b=5
x=(a&b)|(a&a)|(a|b)
print("x")
A. 1
B. 5
C. 0
D. None of the above
Answer : D
Explanation: Output of the following python code x. Therefore output is none of the above.
92. What will be the output of the following program on execution?
if False:
print ("inside if block")
elif True:
print ("inside elif block")
else:
print ("inside else block")
A. inside if block
B. inside elif block
C. inside else block
D. Error
Answer : B
Explanation: Output of the following python code is inside elif block. Therefore Option B is correct.
93. Which of the following statements are correct?
(i) Python is a high level programming language.
(ii) Python is an interpreted language.
(iii) Python is a compiled language.
(iv) Python program is compiled before it is interpreted.
A. i, ii
B. i, iv
C. ii, iii
D. ii, iv
Answer : B
Explanation: Python is a high level programming language and Python program is compiled before it
is
interpreted is correct statement.
94. Which of the following is incorrect variable name in Python?
A. shaurya_1
B. shaurya1
C. @shaurya
D. _shaurya
Answer : C
Explanation: @ variable is incorrect variable name in Python.The Option C is correct.
95. What will be the output of following Python code snippet?
str1="012"
num1=2
num2=0
for i in range(4):
num1+=2
for j in range(len(str1)):
num2=num2+num1
num3=num2%int(str1)
print(num3)
A. 7
B. Infinite Loop
C. 0
D. Error
Answer: C
Explanation: The Output for the following code is 0. So, Option C is correct.
96. What will be the result of following Python code snippet after execution?
str1=""
i=0
var2=1
while(i<3):
var1=1
if str1:
var2=var1*var2+5
else:
var2=var1*var2+1
i=i+1
print(var2)
A. 16
B. 12
C. 11
D. 4
Answer : D
Explanation: The Output for the following code is 4. So, Option D is correct.
97. Which of the following is not a relational opeartor in Python?
A. >=
B. <=
C. =
D. !=
Answer : C
Explanation: = is not considered as a relational operator in Python. So Option C is correct.
98. Suppose we have two sets A & B, then A < B is:
A. True if len(A) is less than len(B).
B. True if A is a proper subset of B.
C. True if the elements in A when compared are less than the elements in B.
D. True if A is a proper superset of B.
Answer : B
Explanation: If A is proper subset of B then hence all elements of A are in B but B contains at least
one
element that is not in B.
99. What is a python file with .py extension called?
A. package
B. module
C. directory
D. None of the above
View Answer
Ans : B
Explanation: python file with .py extension called module. So, Option B is correct.
100. If str1="Programmer Shaurya"
What does str1.find("m") return?
A. Number of occurances of "m" in string str1.
B. Index positions of "m" in the string str1.
C. It returns the whole string str1 if it contains "m".
D. It returns the index position of first occurance of "m" in the string str1.
Answer : D