Explain string type In python
1) Internally string is an array and treat as array of char.
2) Is immutable object and created with single quotes or double quotes.
3) You can use escape char in between string. If you use r letter before string then its meaning is raw string.
4) Formatting also applied on string in python 3.6. Curly braces are replaced by format method value in python 3 version.
>>> n=42
>>> s=this is my string. No is {}.format(n)
>>> print(s)
this is my string. No is 42
5) We can not change the or assign value in between string be coz string is immutable.
Ex. s[1]=j -- is impossible.
2) Is immutable object and created with single quotes or double quotes.
3) You can use escape char in between string. If you use r letter before string then its meaning is raw string.
4) Formatting also applied on string in python 3.6. Curly braces are replaced by format method value in python 3 version.
>>> n=42
>>> s=this is my string. No is {}.format(n)
>>> print(s)
this is my string. No is 42
5) We can not change the or assign value in between string be coz string is immutable.
Ex. s[1]=j -- is impossible.
Comments
Post a Comment