Advertisements
Advertisements
Question
Is data of different types treated differently in Python? Support your answer with an example.
Code Writing
Short Answer
Advertisements
Solution
No. Python treats all names uniformly, irrespective of whether they refer to numbers, strings, functions, classes or other objects. A name can refer to only one object at a time.
var = 15
print(var)
var = "Hello" # var is now bound to a string
print(var)
def var(number): # var is now bound to a function
return number * 10
print(var(5))
15
Hello
50
Each new binding replaces the previous binding of var.
shaalaa.com
Is there an error in this question or solution?
