Professional Documents
Culture Documents
Class 7 String Data Type Sliceing
Class 7 String Data Type Sliceing
ex:-
>>> s = 'scodeen'
10--->int
'scodeen'--->str
10.5--->float
ex:-
x = eval(input('First number:'))
y = eval(input('second number'))
print(x+y)
10--->int
'scodeen'--->str
10.5--->float
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
Output:-
10--->int
'scodeen'--->str
10.5--->float
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
Output:-
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
10--->int
'scodeen'--->str
10.5--->float
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
>>> type(s)
<class 'str'>
>>> type(s1)
<class 'str'>
>>>
by using single quotes or double quotes we can not represent multiline string
literals,so that for the multiline string we are using triple quotes.
def whtsapp_setting_dept(self):
a.self = a
slicing of strings.
slice means a piece.
[] operators is called slice operator,which can be used ti retrive parts of string.
Rules:-
variable [start:end+1:steps]
>>> s = 'scodeen'
>>> s[0]
's'
>>> s[-1]
'n'
>>> s[6]
'n'
>>> s[0:3]
'sco'
>>> s[0::2]
'soen'
>>> s[-0]
's'
>>> s[0::]
'scodeen'
>>> s[0::2]
'soen'
>>> s[0:5:2]
'soe'
>>>
ans:- dir()