Can anyone explain me difference in python shell between output variable through “print” and when I just write variable name to output it?
>>> a = 5
>>> a
5
>>> print a
5
>>> b = 'some text'
>>> b
'some text'
>>> print b
some text
When I do this with text I understand difference but in int or float – I dont know.
Just entering an expression (such as a variable name) will actually output the representation of the result as returned by the
repr()function, whereasprintwill convert the result to a string using thestr()function.>>> s = “abc”Printing
repr()will give the same result as entering the expression directly: