20 questions
What is a correct syntax to return the first character in a string?
x="Hello".sub(0,1)
x="Hello"[0]
x=sub("Hello",0,1)
x=substring("Hello",0,1)
Identify the below expressions which would result in False?
a) False and True b) 1==1 or 2==1
c) 1==1 and 2!=1 d) True and 1==1 e) False or 1>2
c, d
a, e
b, c, d
a, c
what is the output of the below code snippet?
num1=10
num2=7//2
num2*=num1
print(num2)
10
35.0
30
30.0
y = 4
z = lambda x : x ** y
print z(3)
81
12
64
None of the above
What is the output of the below code snippet?
P 9
Q 10
R 2
S 6
Tuple is immutable, so it will throw an error
P 9
Q 10
R 2
S 6
T 6
None of the above
What is the output of the below code?
num_list = [10.5,30.5,-1.20,10.10]
num_list.insert(-3, -10.5)
num_list.pop(0)
print(num_list[0])
30.5
-10.5
10.1
-1.2
What is the output of the code given below?
got it
lcome to Hyd
come to Hyd
come to Hyde
print(~~~~~5)
5
-6
10
-10
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
['ab','cd']
['AB','CD']
what's the value of the below code snippet?
a,b,c = 1,2,3
a,b,c = c,a,b = b,a,c = c,b,a
print(a,b,c)
1 2 3
2 3 1
3 2 1
1 3 2
what is the output of this code snippet?
5 10 10 10
15 10 10 10
15 10 10 20
5 10 10 20
What is the output of the below code snippet?
tup1=([3,6],[2,1])
list1=[(8,9),(7,0)]
list2=tup1[0]
list2[1]=5
list1[1]=(5,2)
print(tup1,list1)
([3,6],[2,1]) [(8,9),(5,2)]
error
([3,5],[2,1]) [(8,9),(5,2)]
What is the output of the below code snippet?
Before Swapping: name1=Federer, name2=Nadal
After Swapping: name1=Federer, name2=Nadal
Before Swapping: name1=Nadal, name2=Federer
After Swapping: name1=Federer, name2=Nadal
Before Swapping: name1=Federer, name2=Nadal
After Swapping: name1=Nadal, name2=Federer
Find the output of the below code snippet:
30
33
39
38
What's the output of the below code?
D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}
D['1'] = 2
print(D[D[D[str(D[1])]]])
'1'
1
3
'2'
What is the output of the below code?
{0: 0, 1: 0, 2: 0}
{0: 1, 1: 1, 2: 1
{0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
TypeError: Immutable object
What is the output of the below code?
10
10
[5, 10, 15]
[5, 10, 15, 20]
10
10
[5, 10, 15]
[5, 10, 15]
10
20
[5, 10, 15]
[5, 10, 15, 20]
10
20
[5, 10, 15]
[5, 10, 15]
What is the output of the below code snippet?
Value error
Finally
Done
Type error
Finally
Done
Type error
Finally
Value error
Finally
L = [1, 3, 5, 7, 9]
print(L.pop(-3), end = ' ')
print(L.remove(L[0]), end = ' ')
print(L)
5 1 [3, 7, 9]
5 None [1, 3, 7, 9]
5 None [3, 7, 9]
What's the output of the below code snippet?
from math import sqrt
L1 = [x**2 for x in range(10)].pop()
L1 += 19
print(sqrt(L1), end = " ")
L1 = [x**2 for x in reversed(range(10))].pop()
L1 += 16
print(int(sqrt(L1)))
10.0 4
4.35 4
10 4
None of the above