0

If we have :

K = [3,4,5]
T = (3,4,5)

and we call these commands :

print(type(K))
print(type(T))

we have these prints :

<class 'list'>
<class 'tuple'>

I know that K is a list and T is a tuple, but I'm not sure whether K or T are also classes or not ? We have commands like K.append() and similar commands, this makes me unsure about the concept.

2 Answers2

0

K and T are instances of python's List and Tuple data types. Types generally have some associated attributes, just like classes. See more about data structures and implementation here.

These are not necessarily class objects, however. This SO post should clarify the difference between a data type and a class.

Community
  • 1
  • 1
0

List and tuple are build-in classes in Python, that's why you can write list() to create a list and tuple() to create a tuple. You just creating an instance of the class list/tuple. You can also deckare a list by using "[" and "]" and a tuple by using "(" and ")", because these so called "operators" are standard syntax of Python.

YpsilonZett
  • 100
  • 1
  • 7