More than one key can have the same value
The values of the dictionary can be accessed as dict[key]
Values of a dictionary must be unique
Values of a dictionary can be a mixture of letters and numbers
[3, 4, 5, 20, 5, 25, 1]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
3
5
25
1
test = {1:'A', 2:'B', 3:'C'}test = {} print(len(test))
0
None
An exception is thrown
What will be the output of the following Python code?
d = {0, 1, 2}for x in d: print(x)
0 1 2
{0, 1, 2} {0, 1, 2} {0, 1, 2}
error
none of the mentioned
What is the output of following code
a = [5,2,3]print(a[5:])
Error
[ ]
Heeeo
Heelo
Heleo
d = {}
d = {“john”:40, “peter”:45}
d = {40:”john”, 45:”peter”}
All of the mentioned
{}
[]
<>
()
a={1:"A",2:"B",3:"C"}for i in a: print(i,end=" ")
1 2 3
‘A’ ‘B’ ‘C’
1 ‘A’ 2 ‘B’ 3 ‘C’
Error, it should be: for i in a.items():
myList = [1, 2, 3, 4, 5, 6]for i in range(1, 6): myList[i - 1] = myList[i] for i in range(0, 6): print(myList[i], end = " ")
2 3 4 5 6 1
6 1 2 3 4 5
2 3 4 5 6 6
1 1 2 3 4 5
In Python, a tuple can contain only integers as its elements.
In Python, a tuple can contain only strings as its elements.
In Python, a tuple can contain both integers and strings as its elements.
In Python, a tuple can contain either string or integer but not both at a time.
What is the output of the following code?
a = {1:"A", 2: "B", 3: "C"}b = {4: "D", 5: "E"}a.update(b)print(a)
{1:’A’, 2: ‘B’,3: ‘C’}
{1: ‘A’, 2: ‘b’, 3: ‘c’, 4: ‘D’, 5: ‘E’}
{4: ‘D’, 5: ‘E’}
{1: ‘A’, 2: ‘B’}
dict([[1,”A”],[2,”B”]])
{1,”A”,2”B”}
{ }
a={1:"A",2:"B",3:"C"}b=a.copy()b[2]="D" print(a)
Error, copy() method doesn’t exist for dictionaries
{1: ‘A’, 2: ‘B’, 3: ‘C’}
{1: ‘A’, 2: ‘D’, 3: ‘C’}
“None” is printed
(1)
(1,)
[1]
{1}
d1={"abc":5,"def":6,"ghi":7}print(d1[0])
abc
{"abc":5}
copy = list(original)
copy = original[:]
copy = original.copy()
All of the above
Slicing
Concatenation
Deletion of elements
Iteration
What will the output of following code?
a={1,2,3}b={1,2,3,4}c=a.issuperset(b)print(c)
False
True
Syntax error for issuperset() method
Error, no method called issuperset() exists
What is the output of the following code:
L=['a','b','c','d']print ( "".join(L))
abcd
[‘a’,’b’,’c’,’d’]
a={} a[2]=1 a[1]=[2,3,4] print(a[1][1])
[2,3,4]
2
a = {}a[1] = 1a['1'] = 2a[1]=a[1]+1count = 0for i in a: count += a[i]print(count)
4
Error, the keys can’t be a mixture of letters and numbers
x = "abcdef"i = "a"while i in x: x = x[:-1] print(i, end = " ")
i i i i i i
a a a a a a
a a a a a
d = {0: 'a', 1: 'b', 2: 'c'}for x in d.values(): print(x)
a b c
0 a 1 b 2 c
What will be the output of the following ?
print((range(4)))
0,1,2,3
[0,1,2,3]
range(0, 4)
(0,1,2,3)
A collection of ordered and mutable data
A collection of unordered and mutable data with key-value pairs
A collection of immutable key-value pairs
A collection of values only
Membership
empty_tuple = ()
empty_tuple = tuple()
empty_tuple = []
Both A and B
insert()
append()
extend()
add()
example = "helle"print(example.find("e"))
-1
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
example = "snow world"example[3] = 's'print (example)
snow
snow world
snos world
Built in
List
Tuple
Derived data
list1 = [11, 2, 23]list2 = [11, 2, 2]print(list1 < list2)
x = "abcdef" i = "a" while i in x[:-1]: print(i, end = " ")
a a a a a a … infinite Time
a
Removes all spaces from the string.
Removes the first and last character of the string.
Removes whitespace from the beginning and end of the string.
Converts the string into a list of characters.
print("abc DEF".capitalize())
abc def
ABC DEF
Abc def
Abc Def
del
remove
removeAll
None of these
print('ab'.isalpha())
d = {0, 1, 2}for x in d: print(d.add(x))
0 1 2 0 1 2 0 1 2 …
None None None
None of the mentioned
set()
( )
Dictionary
Set
None of the Above
slicer
None of these-
d = {0: 'a', 1: 'b', 2: 'c'}for i in d: print(i)
x = 'abcd'for i in range(len(x)): x[i].upper()print (x)
ABCD
d = {"john":40, "peter":45}print("john" in d)
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[1, 3]
[4, 3]
[1, 4]
[1, 3, 4]