In string literals we can use escape characters to associate a special meaning
>>> s=“demo\ndemob”
>>> print(s)
demo
demob
>>> s=“demo\ndemob”
>>> print(s)
demo demob
>>> s=“This is “symbol”
File “<stdin>”, line 1
s=“This is “ symbol”
^
SyntaxError: invalid syntax
>>> s=“This is \” symbol”
>>> print(s)
This is “ symbol
The following are various important escape characters in python
\n —> New line
\t —> horizontal tab
\r —> carriage return
\b —> back space
\f —> form feed
\v —> vertical tab
\’ —> single quote
\” —> double quote
\\ —> back slash symbol
Constants
Constants concept is not applicable in python
But it is convention to use only uppercase characters if we don’t want to change value
MAX_VALUE = 10
It is just convention but we can change the value.
No comments:
Post a Comment