Difference between type() and print(type())

I cant get a clear idea of difference between outputs of type() and print(type()) as shown in question 4 wrt question 3 of this test

Hello Kunal, there is as such not any difference between type() and print(type()) generally we use print(type()) but when we are using the terminal or the jupyter notebook then normally running the variable names or the statement like type() also works.
For ex. In jupyter notebook
Input:
a = 5
a
Output:
5
For ex. Normal py file
Input:
a = 5
print(a)
Output:
5
basically all i mean to say in jupyter notebook that is like the interactive notebook or the terminal both will work type() and the print(type()) but for the normal .py file you need to print that using print().

I hope it is clear to you. Incase there is any doubt/confusion you can ask me I will help you out, just let me know about that.
And if it is clear to you pls mark it as resolve and provide the feedback/rating so that we can improve our services.
Thanks :slight_smile:
Happy Coding !!

Actually my question was if I write
s=(‘CodingBlocks’,4)
type(s)
the output comes as tuple
but for
s=(‘CodingBlocks’)
print( type(s))
output is string,It should also be tuple

No, it is right by only enclosing inside the parenthesis doesn’t guarantee it to be a tuple. Because if it contains only one element it can also be treated as a string or a number. Put comma for that if you want it to result in a tuple.
For eg., if you use as normal as you have written above it will result in a string type
s=(‘CodingBlocks’)
print( type(s))
the output is a string
but if we put a comma in that it will result in a tuple
s=(‘CodingBlocks’,)
print( type(s))
the output is a tuple
Here what I have done is put a comma after ‘CodingBlocks’ this comma will ensure that more elements will also come here.
I hope it is clear to you. Incase still there is any confusion pls ask, I will surely help you out.
And if it is clear to you pls mark it as resolve and provide the feedback/rating so that we can improve ourselves.
Thanks :slight_smile:
Happy Coding !!