English

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

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?
Chapter 3: Classes in Python - EXERCISE [Page 62]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 3 Classes in Python
EXERCISE | Q 3. | Page 62
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×