"print" implicitly performs string conversion so you get the same output either way.
Special Methods
In Python, certain special names are invoked by the Python interpreter in special circumstances. For instance, the init method of a class is automatically invoked whenever an object is constructed. The str method is invoked automatically when printing, and repr is invoked in an interactive session to display values.
There are special names for many other behaviors in Python. Some of those used most commonly are described below.
True and false values. We saw previously that numbers in Python have a truth value; more specifically, 0 is a false value and all other numbers are true values. In fact, all objects in Python have a truth value. By default, objects of user-defined classes are considered to be true, but the special bool method can be used to override this behavior. If an object defines the bool method, then Python calls that method to determine its truth value.
Let’s try literals of different built-in types and see what comes out:
print(42) # <class 'int'>
42
print(3.14) # <class 'float'>
3.14
print(1 + 2j) # <class 'complex'>
(1+2j)
print(True) # <class 'bool'>
True
print([1, 2, 3]) # <class 'list'>
[1, 2, 3]
print((1, 2, 3)) # <class 'tuple'>
(1, 2, 3)
print({'red', 'green', 'blue'}) # <class 'set'>
{'red', 'green', 'blue'}
print({'name': 'Alice', 'age': 42}) # <class 'dict'>
{'name': 'Alice', 'age': 42}
print('hello') # <class 'str'>
hello