>>> list = ['tanvir', 2.3, "raj", 2]
>>> dict = { first:"tanvir",last:"raj",age:23}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'first' is not defined
>>> dict = { "first":"tanvir",last:"raj",age:23}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'last' is not defined
>>> dict = { "first":"tanvir","last":"raj","age":23}
>>> list
['tanvir', 2.3, 'raj', 2]
>>> list.append("raj")
>>> list
['tanvir', 2.3, 'raj', 2, 'raj']
>>> tup = 12,33,"tanvir"
>>> tup
(12, 33, 'tanvir')
>>> r = ("sumit", "kabir",223)
>>> r
('sumit', 'kabir', 223)
>>> r.append("sa")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'append'
>>> list
['tanvir', 2.3, 'raj', 2, 'raj']
>>> list[1]
2.3
>>> list
['tanvir', 2.3, 'raj', 2, 'raj']
>>> list[1:3]
[2.3, 'raj']
>>> len(list)
5
>>> len("this is a programme")
19
>>> list
['tanvir', 2.3, 'raj', 2, 'raj']
>>> list[::3]
['tanvir', 2]
>>> list[:-1]
['tanvir', 2.3, 'raj', 2]
>>> for i in list:
... print(i)
...
tanvir
2.3
raj
2
raj
>>> for i in list[:2]:
... print(i)
...
tanvir
2.3
>>> for i in list[2]:
... print(i)
...
r
a
j
>>> for i in range(10):
... print(i)
...
0
1
2
3
4
5
6
7
8
9
>>> for i in range(1...10):
File "<stdin>", line 1
for i in range(1...10):
^
SyntaxError: invalid syntax
>>> for i in range(1,10):
... print(i)
...
1
2
3
4
5
6
7
8
9
>>> for i in range(2,10, 3):
... print(i)
...
2
5
8
>>> for i in range(2,10):
... if i%2 == 0:
... print(i)
...
2
4
6
8
>>> type(list)
<type 'list'>
>>> type(r)
<type 'tuple'>
>>> dic(list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'dic' is not defined
>>> dict(list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'dict' object is not callable
>>> dir(list)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>>