नीचे दिए गए कोड स्निपेट में 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)
B)
C)
D)
Explanation:
In the given code snippet:
var = 10
: Initially,var
is assigned the value10
, which is an integer, so its type isint
.var = "Hello"
: Then,var
is 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.