हिंदी

Is data of different types treated differently in Python? Support your answer with an example.

Advertisements
Advertisements

प्रश्न

Is data of different types treated differently in Python? Support your answer with an example.

कोड लेखन
लघु उत्तरीय
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: Classes in Python - EXERCISE [पृष्ठ ६२]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 3 Classes in Python
EXERCISE | Q 3. | पृष्ठ ६२
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×