Python Programming - Data Types
Exercise : Data Types - General Questions
- Data Types - General Questions
31.
Which of the following data types is mutable?
Answer: Option
Explanation:
Lists in Python are mutable, meaning their elements can be changed after the list is created.
32.
What is the purpose of the
type()
function?
Answer: Option
Explanation:
The
type()
function is used to determine the type of a variable.
33.
What is the output of the following code snippet?
my_list = [1, 2, 3, 4, 5]
print(my_list[1:4])
Answer: Option
Explanation:
Slicing is used to extract a portion of a list. The specified range is
[1:4]
, which includes elements at indices 1, 2, and 3.
34.
How do you convert a floating-point number to an integer?
Answer: Option
Explanation:
The
int()
function can be used to convert a floating-point number to an integer by truncating the decimal part.
35.
What is the purpose of the
append()
method in Python lists?Answer: Option
Explanation:
The
append()
method is used to add an element to the end of a list.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers