What is the output of the following code ?
ms = ('A','D', 'H','U','N','I','C')print(ms[1:4])
(‘D’, ‘H’, ‘U’)
(‘A’, ‘D’, ‘H’,’U’,’N’,’I’,’C’)
(‘D’,’H’,’U’,’N’,’I’,’C’)
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('xyy', 2, 11))
2
0
1
error
What is the output of the following statement ?
print ((2, 4) + (1, 5))
(2 , 4), (4 , 5)
(3 , 9)
(2, 4, 1, 5)
Invalid Syntax
What will be the output of the following Python code snippet?
print('11'.isnumeric())
True
False
None
Error
list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
[1, 3]
[4, 3]
[1, 4]
[1, 3, 4]
What will be the output of the following code snippet?
a=[1,2,3,4,5,6,7,8,9]a[::2]=10,20,30,40,50,60print(a)
ValueError: attempt to assign sequence of size 6 to extended slice of size 5
[10, 2, 20, 4, 30, 6, 40, 8, 50, 60]
[1, 2, 10, 20, 30, 40, 50, 60]
[1, 10, 3, 20, 5, 30, 7, 40, 9, 50, 60]
find()
copy()
upper()
capitalize()
t1=1,2,4
t1=(1,)
t1=tuple(“123”)
All of these
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
a={}a['a']=1a['b']=[2,3,4] print(a)
Exception is thrown
{‘b’: [2], ‘a’: 1}
{‘b’: [2], ‘a’: [3]}
{'a': 1, 'b': [2, 3, 4]}
d = {0: 'a', 1: 'b', 2: 'c'}for i in d: print(i)
0 1 2
a b c
0 a 1 b 2 c
none of the mentioned
What is the output of following code
x = [1, 2, 3]print(x[1:10])
[2, 3]
[1, 2, 3]
[]
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
print('1.1'.isnumeric())
Which of the following will delete key-value pair for key="tiger" in dictionary?
dic={"lion":"'wild","tiger":"'wild",'cat":"domestic","dog":"domestic"}
del dic("tiger")
dic["tiger"].delete()
delete(dic.["tiger'])
del dic["tiger"]
x = ['ab', 'cd']for i in x: i.upper() print(x)
[‘ab’, ‘cd’]
[‘AB’, ‘CD’]
[None, None]
str1="helloworld"print(str1[::-1])
dlrowolleh
hello
world
helloworld
word1="Apple" word2="Apple" list1=[1,2,3] list2=[1,2,3] print(word1 is word2) print(list1 is list2)
True True
False True
False False
True False
print(max("what are you"))
u
t
y
d1 = {"john":40, "peter":45}d2 = {"john":466, "peter":45}print(d1 == d2)
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’}
Heeeo
Heelo
Heleo
What will be the output?
d = {"a": 1, "b": 2}print(2 in d)
KeyError
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.
pop()
delete()
remove_last()
delete_last()
List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both List and Tuple are Mutable
Both List and Tuple are Immutable
Sequence value pair
Key value pair
Tuple value pair
Record value pair
What is the output of the following?
print(max([1, 2, 3, 4.] [4, 5, 6], [7]))
[4,5, 6
[7]
[1, 2,3, 4]
7
print('xyxxyyzxxy'.lstrip('xyy'))
zxxy
xyxxyyzxxy
xyxzxxy
x | y
x ^ y
x & y
x – y
[25, 20, 5, 5, 4, 3, 3, 1]
[3, 1, 25, 5, 20, 5, 4, 3]
More than one key isn’t allowed
Keys must be immutable
Keys must be integers
When duplicate keys encountered, the last assignment wins
a = [1,2,3]del a[1]print(a)
[1,2,3]
[1,3]
[2,3]
{ }
set()
[ ]
( )
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
startswith()
startswith_prefix()
startswithwith()
startswiths()
a={1:"A",2:"B",3:"C"}a.setdefault(4,"D") print(a)
{1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}
[1,3,6,10]
test = {1:'A', 2:'B', 3:'C'}del test[1]test[1] = 'D'del test[2]print(len(test))
Error as the key-value pair of 1:’A’ is already deleted
list
set
tuple
dictionary
White Space
,
e
S
. List is mutable & Tuple is immutable
Both are mutable
Both are immutable
numbers = {}letters = {}comb = {}numbers[1] = 56numbers[3] = 7letters[4] = 'B'comb['Numbers'] = numbers comb['Letters'] = lettersprint(comb)
Error, dictionary in a dictionary can’t exist
‘Numbers’: {1: 56, 3: 7}
{‘Numbers’: {1: 56}, ‘Letters’: {4: ‘B’}}
{‘Numbers’: {1: 56, 3: 7}, ‘Letters’: {4: ‘B’}}
x = 'abcd'for i in range(len(x)): x[i].upper()print (x)
abcd
ABCD
input(“Enter a string”)
eval(input(“Enter a string”))
enter(“Enter a string”)
eval(enter(“Enter a string”))
print('abcdefcdghcd'.split('cd', -1))
[‘ab’, ‘ef’, ‘gh’]
[‘ab’, ‘ef’, ‘gh’, ”]
(‘ab’, ‘ef’, ‘gh’)
(‘ab’, ‘ef’, ‘gh’, ”)
s.__len__()
len(s)
size(s)
s.size()
length
length()
len()
What will be printed?
a = [[1, 2], [3, 4]]print(a[1][0])
3
4
Dictionary
Tuple
Set
List