WorksheetsSequences
Total questions: 10
Worksheet time: 3mins
What will be the output of the following Python statement?
>>>"a"+"bc"
a
bc
bca
abc
What will be the output of the following Python code?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
olleh
hello
h
o
Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
5
4
None
Error
What will be the output of the following Python code?
>>>names = ['Amir', 'Bear', 'Charlton', 'Daman'] >>>print(names[-1][-1])
A
Daman
Error
n
What will be the output of the following Python code snippet?
print([i.lower() for i in "HELLO"])
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
‘hello’
[‘hello’]
hello
What will be the output of the following Python code snippet?
>>> d = {"john":40, "peter":45}
>>> "john" in d
True
False
None
Error
What will be the output of the following Python code snippet?
>>> d1 = {"john":40, "peter":45}
>>> d2 = {"john":466, "peter":45}
>>> d1 > d2
True
False
Error
None
What will be the output of the following Python code?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
[2,3,9]
[1,2,4,3,8,9]
[1,4,8]
(1,4,8)
What will be the output of the following Python code?
>>> nums = set([1,1,2,3,3,3,4,4])
>>> print(len(nums))
7
4
Error: Invalid formation of syntax of set
8
Which of the following statements is used to create an empty set?
{ }
set()
[ ]
( )
