1.

Explain the difference between the two statements mentioned below: T1=(5) #statement 1 T1=(5,) #statement 2​

Answer»

Answer:

Given statements:

T1 = (5) #statement 1

T2 = (5,) #statement 2

The main difference between these two statements is that T1 is a variable of type int and T2 is a tuple.

This can be understood by a simple program.

T1=(5)

T2=(5,)

print("T1:",T1)

print("T2:", T2)

print("type(T1):",type(T1))

print("type(T2):",type(T2))

★ The type() FUNCTION returns the class type of the argument.

The OUTPUT of the above program is:

T1: 5

T2: (5,)

type(T1):

type(T2):

This clearly says that T1 BELONGS to class 'int' and T2 is a tuple.

•••♪



Discussion

No Comment Found