What will be the output?
a = [1, 2, 3] print(a + [4, 5])
[1, 2, 3, 4, 5]
[5, 7, 8]
Error
[4, 5, 1, 2, 3]
t = (5) print(type(t))
<class 'tuple'>
<class 'int'>
<class 'list'>
(10)
[10]
(10,)
{10}
t = (1, 2, 3) t[1] = 5 print(t)
(1, 5, 3)
(1, 2, 3)
None
a, b, c = (10, 20, 30) print(b)
10
20
30
d = {"a": 1, "b": 2} print(2 in d)
True
False
KeyError
a={'a':4,'b':6,'a':7} print(a)
{'a': 5, 'b': 6,'a': 7 }
{'a': 7, 'b': 6}
{'a': 5, 'b': 6 }
Key Error
dict1={'a':[3,6,8]} print(len(dict1))
3
2
1
Indexing
Slicing
Concatenation
Element assignment
List
Dictionary
Set
Tuple
What does the following slice return?
s = [0,1,2,3,4,5] print(s[1:5:2])
[1, 3]
[2, 4]
[1, 2, 3, 4]
[0, 2, 4]
strip()
lstrip()
rstrip()
trim()
{1, 2, 3}
[1, 2, 3]
{}
Row 1
Column 2
Element at row 1, column 2
Entire second row
Dictionary keys must be mutable
Dictionary values must be immutable
Dictionary reserves insertion order only in Python 2
Dictionary keys must be unique
Output of the code:
t = (10, 20, 30) t += (40,) print(t)
(10, 20, 30)
(10, 20, 30, 40)
(40,)
What is the output?
s = "Python" print(s[-1:-4])
hon
hon in reverse
IndexError
Empty string
Index of 'a'
Frequency of 'a'
Boolean
What is the output of following?
lst = [1, 2, 3, 4] print(lst[::-1])
[4, 3, 2, 1]
a = [1, 2, 3] b = a b.append(4) print(a)
[4]