Professional Documents
Culture Documents
3. If you use '' outside then it is fine to use '' inside"" and vice versa.
x+9=11
_ +y=14
case1: name='ashish'
name[0]='a'
case2: If negative integer is used then, the element's counting starts from right
to left----------ashish(-6,-5,-4,-3,-2,-1)
name[-1]='h'
6. For printing more than one element of a string array then we use --- name[a:b]=where
a is starting element postion and b is how many elements have to be printed starting from
name[0]
case1: name[0:3]='ash'
case2: name[2:4]='hi'
Page 2 of 5
case3: name[2:]='hish'
case4: name[:3]='ash'
case5: name[2:10]='hish'
'b'+name[1:5]='bshish'
8. Functions--------------
num=[1,2,3,4,5]
name=['a','b','c','d']
mix=[num,name]
mix=[1,2,3,4,5],['a','b','c','d']
num=[1,2,3,4]
append=used to extend the list by adding elements in the last of the list
num.append(6)
num=[1,2,3,4,6]
num=[1,2,5,3,4,6]
num.remove(2)
num=[1,5,3,4,6]
pop=used to remove elemets from the list when index no. is given
num.pop(2)
num=[1,5,4,6]
del num[2:4]
num=[1,5]
num.extend([7,8,9])
num=[1,5,7,8,9]
min(num)=1
sum(num)=30
11. Tuple :-
It is used when an user wants that the elements can not be changed. Instead of
square brackets , small brackets are used
12. Set:-
Set is same as lists but it does not follow any specific order. { } are used to represent
set. A set does not support duplicate values.
Numeric---------------
1. int=1,2,3
2. float=1.2,3.4
3. complex=3+5j
*if only the int part of a variable is to be used then use int(variable)
lists
tuple
set
string
range---reprentation= range(10)=(0,10)
dictionary-----------
In dictionary , an element is represented by its key
Page 5 of 5
d={‘ashish’:’honor’,’abhay’:’samsung’}
d[‘ashish’]=’honor’ or d.get(‘ashish’)=’honor’
d.keys=({‘ashish’,’abhay’})
d.values=({‘honor’,’samsung’})
*we use curley brackets in dictionary because the keys cannot be same and we know
that the elements of sets donot repeat.