नीचे दिए गए कोड स्निपेट में var का डेटाटाइप क्या होगा?
What will be the datatype of the var in the below code snippet?
var = 10
print(type(var))
var = "Hello"
print(type(var))
A
str and int
B
int and int
C
str and str
D
int and str
Explanation
In the given code snippet:
var = 10: Initially,varis assigned the value10, which is an integer, so its type isint.var = "Hello": Then,varis assigned the value"Hello", which is a string, so its type becomesstr.
Thus, the data type of var changes from int to str as the value is reassigned.
Correct answer: (D) int and str.
Correct Answer: D) int and str