0% found this document useful (0 votes)
30 views3 pages

Class 7

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Class 7

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

5.

String Data Type(str)

str represent string data type.

A String is a sequence of characters enclosed within sigle quotes('') or double


quotes("") or triple quotes(''' ''',""" """)

ex:-
>>> s = 'scodeen'

10--->int
'scodeen'--->str
10.5--->float
ex:-i.low level programming lang.i.Insertion order are preseved.
ii.hetrogeneous object are allowed.
iii.duplicates are allowed.
iv.Growable in nature.
v.values should be enclosed within squre bracket.
1.Arithmetic Operators
2.Relational or comparision operatos
3.Logical OperatosNote:- raw_input functi
x = eval(input('First number:'))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.

Note:- raw_input function of python 2 is renamed as input() function in python3.


Methods of dictionary:-
clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault',
'update', 'values']
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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

y = eval(input('second number'))
print(x+y)
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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

india nai tiobk batuibkeej ubd indian arngudfoaoddofhsdsoihfodhfvx jjsddgf

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.
Note:- raw_input function of python 2 is renamed as input() function in python3.

Output:-

we can write print() function to display outputex:-


x = eval(input('First number:'))
y = eval(input('second number'))
print(x+y)

india nai tiobk batuibkeej ubd indian arngudfoaoddofhsdsoihfodhfvx jjsddgf

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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

Output:-

we can write print() function to display output


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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

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.

Note:- raw_input function of python 2 is renamed as input() function in python3.


>>> 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

''' This function is only use for


whts app setting department'''

slicing of strings.
slice means a piece.
[] operators is called slice operator,which can be used ti retrive parts of string.

In python strings folllows zero based index..

The index can be either +ve or -ve.

+ve index means forward direction from left to right.


-ve index means backward direction form right to left.

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'
>>>

How to check the data type or module or class function?

ans:- dir()

string methods link:- https://www.w3schools.com/python/python_strings_methods.asp

You might also like