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
English,
1 month ago
Economy,
1 month ago
Geography,
3 months ago
English,
10 months ago
Computer Science,
10 months ago