Explain the difference between the two statements mentioned below: T1=(5) #statement 1 T1=(5,) #statement 2
Answers
Answered by
7
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): <class 'int'>
type(T2): <class 'tuple'>
This clearly says that T1 belongs to class 'int' and T2 is a tuple.
•••♪
Attachments:
Similar questions
Physics,
22 days ago
Social Sciences,
22 days ago
Geography,
1 month ago
English,
8 months ago
Computer Science,
8 months ago