+ 3
About the print statement
do we have 2 methods for print statements 1)print("heloo world") 2)print('heloo world') is both corect ????
12 ответов
+ 7
Both are correct. The only difference is that you cannot use " inside double quotes and ' inside single quotes.
+ 5
Yes! Both are correct!
+ 2
Both are correct.
+ 1
Note: print() is a function, not a statement. (In Python3 at least.)
+ 1
u can use " inside a double quote by using \ before" and same for '
+ 1
and there is println too
0
yes, because python makes no difference
0
1) you use " to mark your string
2)you use ' to mark your string
0
yes , you can use both " as well as '
0
yes both are correct, python doesn't differentiates between the two, unlike in Java, where ' ' is used for char and " " is used for string. But still for understanding convince, you can use it for char and string differently.
0
Both of them are correct. Some use cases are as follows.
Suppose you want to print the following:
Python's syntax are easy to understand
then you use:
print("Python's syntax are easy to understand")
if you put the string in single quotes, it will throw an error.
Again, if you want to print
I have a dog named "Tommy"
you have to put that string in single quotes:
print('I have a dog named "Tommy"')
Other than that you can use any. But usually people prefer single quotes to wrap single word string and double quotes for long strings. Use anyone that you are comfortable with.