Python Programming - Data Types
Exercise : Data Types - General Questions
- Data Types - General Questions
51.
How do you check if a variable is of type float?
Answer: Option
Explanation:
The
type()
function is used to check the type of a variable.
52.
What is the output of the following code snippet?
my_dict = {'a': 1, 'b': 2, 'c': 3}
result = 'b' in my_dict
print(result)
Answer: Option
Explanation:
The
in
keyword checks if the specified key is present in the dictionary.
53.
What is the purpose of the
bool()
function?
Answer: Option
Explanation:
The
bool()
function can be used to convert a number to a boolean. 0 becomes False, and any non-zero value becomes True.
54.
What will be the result of the following code snippet?
my_string = "Python"
result = my_string.find("th")
print(result)
Answer: Option
Explanation:
The
find()
method returns the index of the first occurrence of the specified substring.
55.
How do you concatenate two strings?
Answer: Option
Explanation:
The '+' operator is used for string concatenation in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers