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
[x<0 in l]
[x for x<0 in l]
[x in l for x<0]
[x for x in l if x<0]
What will be the output of the following Python code?
t=32.00 for x in t: print(x)
[0]
0
[0.00]
Error
[1, 2, 3]
(1, 2, 3)
{1, 2, 3}
{}
print(t[3])
t[3] = 45
print(max(t))
print(len(t))
Tuple
Integer
List
Both tuple and integer
Error, tuple slicing doesn’t exist
[2,3]
(2,3,4)
(2,3)
Array of tuples
List of tuples
Tuples of lists
Invalid type
a=[(2,4),(1,2),(3,9)] a.sort() print(a)
[(1, 2), (2, 4), (3, 9)]
[(2,4),(1,2),(3,9)]
Error because tuples are immutable
Error, tuple has no sort attribute
Mutable data type
Allows duplicate values
Data type with unordered values
Immutable data type
{ }
set()
[ ]
( )
print(len(a))
print(min(a))
a.remove(5)
a[2]=45
a={5,5,6,7}
a={5,6,7}
Error as there is no add function for set data type
Error as 5 already exists in the set
>>> a={5,6,7} >>> sum(a,5)
5
23
18
Invalid syntax for sum method, too many arguments
a={5,6,7,8} b={7,8,9,10} print(len(a+b))
8
Error, unsupported operand ‘+’ for sets
6
Nothing is displayed
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
keys, keys
key values, keys
keys, key values
key values, key values
s={abs}
s={4, ‘abc’, (1,2)}
s={2, 2.2, 3, ‘xyz’}
s={san}
pop
remove
update
sum