What's the difference between using print ('Hi') and using string "Hi"

8/14/2019 2:29:17 AM


5 Answers

New Answer


whenever you use python console to use verify example codes, then for each line of the code that are entered at each instant, python console responds to that line code, which can be either >>> "Hi" or >>> print("Hi"), here the responds is same for both codes that is Hi, though the reasons behind for those responses are not same. >>> "Hi" in python console responds by outputing Hi that python console received Hi text value at the end of the execution of that line code. In, >>> print("Hi"), python console responds that it is displaying Hi. Now, if we write those two line codes in python script file, and execute that python file in python console, like, Let example.python be the file, and the code content be as follows: "Hi" print("Hi") What output do you see when executing the python scripting file through python console? You will see only one Hi, instead of two Hi. The reason is because while executing through python file, you will see outputs of what the python file code wants display through function like print(), all other intermediate responses that are received by python console are not displayed, which is not the case when you directly enter line codes in the python console, where intermediate responses are default. Let us look at another closely related example from newer perspective. Try this two line of codes directly in python console and also through the python scripting file. And reply. >>> message="Hi" >>> print(message) Hint: look out for the respond for >>> message="Hi" while directly entering in python console... reply your observation....


Each string and character is stored in memory in a different way. But as a result, it can be the same.


there's no difference between "hi" & 'hi' in python.but in c++ for example we use " " for strings & we use ' ' for chars.


The python interpreter's output will be: Hi for the print('Hi') without quote And 'Hi' for just the "Hi" with quote The difference... is that you made use of the function (print)....


same thing