Top 20 Python practice MCQ’s with Answers
Python is one of the most popular programming languages used by developers today.
It is easy to learn, versatile, and can be used for a wide range of applications. However, mastering Python requires a lot of practice, and one of the best ways to do that is by taking multiple-choice questions (MCQs).
In this blog post, we have compiled a list of the top 20 Python practice MCQs with answers to help you test your knowledge and improve your Python skills.
Question 1 : In Python, print () by default adds which of the following as an end line argument?
Options :
a. \t
b. \n
c. \s
d. \r
Answers : b. \n
Question 2 : Which of the following is not true about variable names?
Options :
a. The length of the variable name is fixed
b. Can contain upper case or lowercase letters and digits 0-9
c. Variable names cannot begin with a digit
d. Variable names are case sensitive
Answers : a. The length of the variable name is fixed
Question 3 : What does IDE stand for?
Options :
a. Internet Data Evaluation
b. Integrated Drive Electronics
c. Integrated Development Enterprises
d. Integrated Development Environment
Answers : d. Integrated Development Environment
Question 4 : In Spyder, the command to clear the console is
Options :
a. %reset
b. %delete
c. %del
d. %clear
Answers : d. %clear
Question 5 : Which of the following code cannot be used to initialize multiple variables with a common value?
Options :
a.
b. a, b, c = 55, 55, 55
c.
d. a = 55; b = a; c = b
Answers : a. a, b, c = 55
Question 6 : What will be the output after executing the following codes?
x=45
y=7
x%=y
print(x)
Options :
a. 6
b. 42
c. 3
d. 52
Answers : c. 3
Question 7 : Which of the following is true with respect to the below codes?
a = 4**3
b = pow(4,3)
print(a,b)
Options :
a. a = b
b. a ≠ b
c. a < b
d. a > b
Answers : a. a = b
Question 8 : What will be the output after executing the following codes?
x = 8
if x > 8:
print(20)
else:
print(10)
Options :
a. 20
b. ValueError
c. 10
d. SyntaxError
Answers : c. 10
Question 9 :Which of the following conversion results in an error?
Options :
a.
b.
c. int(10)
d. float(10.8)
Answers : a.
Question 10 :Which of the following command is used to print the output 01-Jan-2020 ?
Options :
a. print(’01’,’Jan’, sep=’ ‘, end=’-2020′)
b. print(’01’,’Jan’, sep=’-‘, end=’-2020′)
c. print(’01’,’Jan’, sep=’-‘, end=’2020’)
d. print(’01’,’Jan’,’2020′, sep=’-‘, end=’-2020\n’)
Answers : b. print('01','Jan', sep='-', end='-2020')
Question 11 :For which type of error does the interpreter runs the program and does not report an error?
Options :
a. Semantic error
b. Syntax error
c.
d. Key error
Answers : a. Semantic error
Question 12 : What will be the output after executing the following codes?
x = 27
y = 4
print(x//y)
Options :
a. SyntaxError
b. 6.75
c. 3
d. 6
Answers : d. 6
Question 13 : Identify which of the following is not a valid variable name?
Options :
a. X005 =10
b. A.2 = 10
c. N_s = 10
d. r10 = 10
Answers : b. A.2 = 10
Question 14 :
Options :
a. Displays the current Python version
b. Displays the operating system version
c. Displays the location of the Python interpreter
d. All of the above
Answers : a. Displays the current Python version
Question 15 : The operators ‘is’ & ‘is not’ are?
a. Comparison Operators
b.
c. Membership Operators
d. Relational Operators
Answers : b.
Question 16 :
a. 4
b.
c. 5
d. 8
Answers : c. 5
Question 17 : What would be the datatype of variable ‘c’ after executing the following code?
a = 5
b = 6
c = print(a/b)
Options :
a. float
b. Nonetype
c. int
d. object
Answers : b. Nonetype
Question 18 : Which is not a valid assignment operator?
Options :
a. **=
b. +=
c. //=
d. %%=
Answers : d. %%=
Question 19 : Which is not a valid bitwise operator?
Options :
a. &
b. ~
c. ^
d. ≤
Answers : d. ≤
Question 20: The datatype of the variable a = (1i) is
Options :
a. str
b. complex
c. SyntaxError
d. tuple
Answers : c. SyntaxError