Python MCQ on Basic Data Types Operators and Expressions with Answers. We covered all the Python MCQ on Basic Data Types Operators and Expressions with Answers in this post for free so that you can practice well for the exam.
Install our MCQTUBE Android app from the Google Play Store and prepare for any competitive government exams for free.
We created all the competitive exam MCQs into several small posts on our website for your convenience.
You will get their respective links in the related posts section provided below.
Related Posts:
- Python Interview Questions MCQ on Core Concepts
- Simple Python Basic Quiz Questions and Answers
- Basic Programming MCQ for Beginners with Answers
Python MCQ on Basic Data Types Operators and Expressions with Answers for Students
Do bitwise shift operators (<
, >>
) take precedence over the bitwise AND (&
) operator?
a. No
b. Yes
Option b – Yes
What will be the result of the expression print(10 - 4 * 2)
?
a. 2
b. 12
Option a – 2
What is the output of the statement print(-18 // 4)
?
a. -4
b. 4
c. -5
d. 5
Option c – -5
What does print(2 % 6)
produce?
a. ValueError
b. 0.33
c. 2
Option c – 2
Which of these correctly declares and initializes a variable x
with the value 5?
a. intX X = 5
b. int x = 5
c. X = 5
d. declare x = 5
Option b – int x = 5
Which among these is not a valid variable name in Python?
a. var
b. var name
c. Var11
d. 11var
Option d – 11var
Identify the incorrect statement about local variables:
a. They can only be used inside the function they are defined in
b. Modifying a local variable doesn’t affect values outside the function
c. They exist in memory until the program finishes
d. None of the above
Option c – They exist in memory until the program finishes
Identify the incorrect statement about global variables:
a. Global variables must be declared as global inside a function to be used there
b. They stay in memory until the program ends
c. They are defined outside of all functions, in the global scope
d. None of the above
Option a – Global variables must be declared as global inside a function to be used there
What is the correct order of precedence for the following operations?
- Exponentiation
- Parentheses
- Multiplication and division
- Addition and subtraction
a. 1, 2, 3, 4
b. 2, 1, 3, 4
c. 1, 2, 4, 3
d. 2, 3, 1, 4
Option c – 1, 2, 4, 3
Which of the following code snippets will produce an error in Python?
a. a+
b. ++a
c. a += 1
d. Both a and b
Option d – Both a and b
Which operator is used in Python to raise a number x to the power of y?
a. x^y
b. x*y
c. x**y
d. None of these
Option c – x**y
If multiple operators have the same priority, how is the expression evaluated?
a. Left to right
b. Right to left
c. Based on the compiler
d. None of these
Option a – Left to right
Is in
considered an operator in Python?
a. True
b. False
c. Depends on usage
d. Not applicable
Option a – True
What result does Python produce when evaluating 2 * 2 ** 2
?
a. 16
b. 256
c. 32768
d. 65536
Option d – 65536
Who is credited with creating the Python programming language?
a. Wick van Rossum
b. Rasmus Lerdorf
c. Guido van Rossum
d. Niene Stom
Option c – Guido van Rossum
Python supports which of the following programming paradigms?
a. Object-oriented
b. Structured
c. Functional
d. All of the above
Option d – All of the above
Are Python identifiers case-sensitive?
a. No
b. Yes
c. Depends on the platform
d. Not defined
Option b – Yes
What is the appropriate file extension for saving Python scripts?
a. python
b. .pl
c. .py
d. .p
Option c – .py
How is Python code executed?
a. It is first compiled and then interpreted
b. It is neither compiled nor interpreted
c. It is only compiled
d. It is only interpreted
Option a – It is first compiled and then interpreted
How are Python’s reserved words typically written?
a. In capitalized form
b. In lowercase
c. In all uppercase
d. No fixed format
Option d – No fixed format
What will be the result of the expression 4 + 3 % 5
in Python?
a. 7
b. 2
c. 4
d. 1
Option a – 7
How are packages best described in Python?
a. A group of primary modules
b. A directory that contains multiple Python modules
c. A collection of Python files with functions and classes
d. A bundle of programs that utilize various Python modules
Option b – A directory that contains multiple Python modules
What is the highest integer value that can be represented using Python’s int
type?
a. 2³² − 1
b. 2⁶³ − 1
c. 2¹⁵ − 1
d. 2⁷ − 1
Option a – 2³² − 1
Which of the following represents a data type that cannot be changed after creation in Python?
a. List
b. Tuple
c. Set
d. Dictionary
Option b – Tuple
When evaluating the expression 5 / 2
in Python, what will be the resulting data type?
a. int
b. float
c. str
d. bool
Option a – int
What is the correct syntax to create an empty list in Python?
a. empty_list = []
b. empty_list = }
c. empty_list = ()
d. empty_list = [None]
Option a – empty_list = []
Which of the following is a changeable sequence type in Python?
a. Tuple
b. List
c. String
d. Set
Option b – List
What does print(3 * 'abc')
output in Python?
a. abcabc
b. abcabcabc
c. Error
d. None
Option b – abcabcabc
What does the pop()
method perform in Python?
a. Appends an item to the end of a list
b. Removes and returns the last element from a list
c. Removes and returns the first element from a list
d. Retrieves the item at a specific index
Option b – Removes and returns the last element from a list
What is the output when you evaluate int("42")
in Python?
a. 42
b. “42”
c. Error
d. 0
Option a – 42
How do you combine two lists in Python?
a. list1.concat(list2)
b. list1 + list2
c. list1.extend(list2)
d. All of the above
Option b – list1 + list2
What is the purpose of the append()
function in Python?
a. Adds an element to the start of a list
b. Adds an element to the end of a list
c. Removes the final element from a list
d. Removes the first element from a list
Option b – Adds an element to the end of a list
Which of these methods is a valid way to create a dictionary in Python?
a. my_dict = (1, 'one', 2, 'two')
b. my_dict = [(1, 'one'), (2, 'two')]
c. my_dict = (1: 'one', 2: 'two')
d. None of the above
Option c – my_dict = (1: ‘one’, 2: ‘two’)
What does the expression 2 ** 3
result in Python?
a. 8
b. 9
c. 5
d. 3
Option a – 8
How can you verify if a value exists in a list in Python?
a. value.exist(list)
b. value in list
c. list.has_value(value)
d. list.contains(value)
Option b – value in list
What is the result of print(10 | 3)
in Python?
a. 3.3333333333333335
b. 3.0
c. 3
d. 3.333
Option a – 3.3333333333333335
Which of these is not a valid method for creating a dictionary in Python?
a. my_dict = dict([(1, 'one'), (2, 'two')])
b. my_dict = {1: 'one', 2: 'two'}
c. my_dict = {1, 'one', 2, 'two'}
d. my_dict = {1: 'one', 'two': 2}
Option c – my_dict = {1, ‘one’, 2, ‘two’}
What is the result of abs(-5)
in Python?
a. 5
b. -5
c. 0
d. 1
Option a – 5
What is the purpose of the enumerate()
function in Python?
a. Returns the index of an element in a list
b. Returns the total sum of all list elements
c. Returns both the index and value of each element in a list
d. Returns the average of all list elements
Option c – Returns both the index and value of each element in a list
Which of the following is a correct way to create a range object in Python?
a. range(5)
b. range(1, 5)
c. range(1, 5, 2)
d. All of the above
Option d – All of the above
Which of the following is the correct method to create a tuple with a single element in Python?
a. single_tuple = (1)
b. single_tuple = (1,)
c. single_tuple = 1,
d. single_tuple = [1]
Option b – single_tuple = (1,)
What will be the result of 5 + 3
in Python?
a. 8
b. 15
c. 53
d. Error
Option a – 8
Which symbol is used for exponentiation in Python?
a. *
b. ^
c. **
d. ex
Option a – **
What is the output of 7 // 2
in Python?
a. 3.5
b. 3
c. 4
d. 2.5
Option b – 3
What does the %
operator represent in Python?
a. Division
b. Modulus
c. Exponentiation
d. Multiplication
Option b – Modulus
What will be the result of 7 / 2
in Python?
a. 3.5
b. 3
c. 4
d. 2.5
Option a – 3.5
Which operator performs floor division in Python?
a. /
b. //
c. %
d. None of the above
Option b – //
What will be the result of the expression 3 * 2 ** 2
in Python?
a. 12
b. 18
c. 24
d. 9
Option c – 24
Which operator is used to concatenate strings in Python?
a. +
b. *
c. /
d. -
Option a – +
What will the expression 2 + 3 * 4
evaluate to in Python?
a. 20
b. 14
c. 18
d. 32
Option c – 18
What is the correct way to comment a single line in Python?
a. // This is a comment
b. # This is a comment
c. /* This is a comment */
d. -- This is a comment
Option b – # This is a comment
What will be the result of True and False
in Python?
a. True
b. False
c. None
d. Error
Option b – False
Which operator is used for the logical OR operation in Python?
a. &&
b. ||
c. or
d. |
Option c – or
What will the result of not True
be in Python?
a. True
b. False
c. None
d. Error
Option b – False
What is the result of 3 = '3'
in Python?
a. True
b. False
c. None
d. Error
Option b – False
Which operator is used for membership testing in Python?
a. in
b. is
c. ==
d. !=
Option a – in
What will be the result of the expression 5 > 3 or 2 < 1
in Python?
a. True
b. False
c. None
d. Error
Option a – True
What is the result of 4 << 1
in Python?
a. 8
b. 2
c. 16
d. 1
Option a – 8
Which operator is used to test identity in Python?
a. is
b. ==
c. !=
d. in
Option a – is
What is the result of the expression 2 ** 3
in Python 2.x?
a. 6
b. 9
c. 8
d. 5
Option c – 8
What does the expression 10 / 3.0
return in Python?
a. 13
b. 13.0
c. 10.3
d. Error
Option b – 13.0
Evaluate the result of the expression 2 + 3 * 4
in Python 2.x.
a. 20
b. 14
c. 18
d. 32
Option b – 14
Which method correctly checks if a number is odd in Python?
a. x % 2 == 0
b. x.is_odd()
c. isodd(x)
d. None of the above
Option a – x % 2 == 0
What is the outcome of the expression True and False
in Python 2.x?
a. True
b. False
c. None
d. Error
Option b – False
How does 10 / 3
evaluate in Python 2.x?
a. 3.3333333333333335
b. 3.0
c. 3
d. 3.333
Option c – 3
Which operator is used for repeating a string in Python 2.x?
a. +
b. *
c. /
d. -
Option b – *
What does the comparison 5 == '5'
result in Python?
a. True
b. False
c. None
d. Error
Option b – False
What happens when you evaluate 5 + '3'
in Python 2.x?
a. 8
b. ’53’
c. 35
d. Error
Option d – Error
Which operator is responsible for float division in Python 2.x?
a. /
b. //
c. %
d. None of the above
Option b – //
What is the outcome of 5 | 2.0
in Python 2.x?
a. 2.5
b. 2
c. 2.0
d. 2.51
Option a – 2.5
How can you create a list of numbers from 1 to 5 in Python 2.x?
a. [1, 2, 3, 4, 5]
b. list(1, 5)
c. range(1, 5)
d. All of the above
Option c – range(1, 5)
What does 5 == '5'
return in Python 2.x?
a. True
b. False
c. None
d. Error
Option b – False
Which operator is used for slicing strings in Python 2.x?
a. :
b. ..
c. :
d. ->
Option a – :
In Python 3.x, what is the result of the expression 5 / 2
?
a. 2.5
b. 2
c. 2.0
d. 2.5
Option d – 2.5
What is the result of 10 / 3
in Python?
a. 3.3333333333333335
b. 3.0
c. 3
d. 3.333
Option a – 3.3333333333333335
How is integer division performed in Python?
a. //
b. /
c. %
d. **
Option a – //
How do you perform a right shift operation in Python?
a. >>
b. <<
c. &
d. |
Option a – >>
What is the result of evaluating 16 >> 2
in Python?
a. 2
b. 4
c. 8
d. 16
Option b – 4
What is the function of the not in
operator in Python?
a. Membership test
b. Exponentiation
c. Identity check
d. Negation of membership test
Option d – Negation of membership test
What will be the output of print(3 not in [1, 2, 3])
in Python?
a. True
b. False
c. None
d. Error
Option b – False
What is the role of the and
operator in Python?
a. Bitwise AND
b. Logical AND
c. Bitwise OR
d. Logical OR
Option b – Logical AND
What is the output of print(10 and 0)
in Python?
a. 10
b. 0
c. True
d. False
Option b – 0
What does print(bool(""))
return in Python?
a. True
b. False
c. None
d. Error
Option b – False
What will be the result of the expression len("Python")
in Python?
a. 6
b. 7
c. 5
d. Error
Option a – 6
How do you perform integer (floor) division in Python?
a. //
b. /
c. %
d. **
Option a – //
What is the result of the expression 7 // 2
in Python?
a. 3
b. 3.5
c. 4
d. 2
Option a – 3
What is the output of print("Python".upper())
in Python?
a. python
b. PYTHON
c. Python
d. python
Option b – PYTHON
How can you combine two lists in Python?
a. list1.concat(list2)
b. list1 + list2
c. list1.extend(list2)
d. All of the above
Option b – list1 + list2
What will list("Python")
return in Python?
a. “Python”
b. ['P', 'y', 't', 'h', 'o', 'n']
c. ('P', 'y', 't', 'h', 'o', 'n')
d. Error
Option b – [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
How can you convert a string to an integer in Python?
a. int(string)
b. string.toInt()
c. int.parse(string)
d. parse(int, string)
Option a – int(string)
What is the result of evaluating bool("False")
in Python?
a. True
b. False
c. Error
d. None
Option a – True
How do you check if a key exists in a dictionary in Python?
a. key in dict
b. key.exist(dict)
c. dict.has_key(key)
d. key.exists(dict)
Option a – key in dict
What will print("hello".capitalize())
output in Python?
a. hello
b. Hello
c. HELLO
d. hELLO
Option b – Hello
Which method can be used to remove an element from a set in Python?
a. set.remove(element)
b. set.discard(element)
c. set.pop()
d. All of the above
Option a – set.remove(element)
We covered all the Python MCQ on Basic Data Types Operators and Expressions with Answers above in this post for free so that you can practice well for the exam.
Check out the latest MCQ content by visiting our mcqtube website homepage.
Also, check out:
- Computer MCQ for Class 10 with Answers PDF
- Computer Science MCQ Quiz for Beginners
- Computer Science MCQ Practice Test with Answers