No student devices needed. Know more
25 questions
What is the output of the following:
aList = [1, 2, 3, 4, 5, 6, 7]
pow2 = [2 * x for x in aList]
print(pow2)
[2, 4, 8, 16, 32, 64, 128]
[2, 4, 6, 8, 10, 12, 14]
[2, 4, 6, 8, 16, 32, 64, 128]
[2,4,6,8,12,14]
What is the output of the following code:
list1 = ['xyz', 'zara', 'PYnative']
print (max(list1))
xyz
PYnative
zara
native
What is the output of the following list operation:
sampleList = [10, 20, 30, 40, 50]
print(sampleList[-2])
print(sampleList[-4:-1])
IndexError: list index out of range
[20, 30, 40]
40
40
[20, 30, 40]
What is the output of the following code:
aList = ["PYnative", [4, 8, 12, 16]]
print(aList[0][1])
print(aList[1][3])
P
12
Y
16
P 8
Y 16
P
8
Y
16
What is the output of the following list function?
sampleList = [10, 20, 30, 40, 50]
sampleList.append(60)
print(sampleList)
sampleList.append(60)
print(sampleList)
[10, 20, 30, 40, 50]
[10, 20, 30, 40, 50]
[10, 20, 30, 40, 50]
[10, 20, 30, 40, 50, 60, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60, 60]
Select the correct options to join two lists in Python:
newList = extend(listOne, listTwo)
newList = listOne + listTwo
newList = listOne.extend(listTwo)
newList.extend(listOne, listTwo)
What is the output of the following:
l = [None] * 10
print(len(l))
10
0
Syntax Error
Logical Error
What is the output of the following list assignment:
aList = [4, 8, 12, 16]
aList[1:4] = [20, 24, 28]
print(aList)
[4, 20, 24, 28,12, 16]
[4, 20, 24, 28]
[4, 20, 24, 28, 8, 12, 16]
[20,24,28]
What is the output of the following list function?
sampleList = [10, 20, 30, 40, 50]
sampleList.pop()
print(sampleList)
sampleList.pop(2)
print(sampleList)
[20, 30, 40, 50]
[10, 20, 40]
[10, 20, 30, 40]
[10, 20, 30, 50]
[10, 20, 30, 40]
[10, 20, 40]
[10, 20, 30, 40]
[10,40]
What will be the output of below Python code?
list1=["tom","mary","simon"]
list1.insert(5,8)
print(list1)
["tom", "mary", "simon", 5]
Error
[8, "tom", "mary", "simon"]
['tom', 'mary', 'simon', 8]
What is the output of the below program?
x = 50
def func():
global x
print('x is', x)
x = 2
print('Changed global x to', x)
func()
print('Value of x is', x)
x is 50
Changed global x to 2
Value of x is 2
x is 50
Changed global x to 2
Value of x is 50
x is 50
Changed global x to 50
Value of x is 50
None of the mentioned
What is the output of below program?
def say(message, times = 1):
print(message * times)
say('Hello')
say('World', 5)
Hello
World
WorldWorldWorldWorldWorld
Hello
WorldWorldWorldWorld
Hello
WorldWorldWorldWorldWorld
What is the output of below program?
def maximum(x, y):
if x > y:
return x
elif x == y:
return 'The numbers are equal'
else:
return y
print(maximum(2, 3))
2
The numbers are equal
2,3
3
What is the output of the below program?
def func(a, b=5, c=10):
print('a is', a, 'and b is', b, 'and c is', c)
func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)
a is 7 and b is 3 and c is 10
a is 25 and b is 5 and c is 24
a is 5 and b is 100 and c is 50
a is 3 and b is 7 and c is 10
a is 5 and b is 25 and c is 24
a is 50 and b is 100 and c is 5
Error
a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
a is 100 and b is 5 and c is 50
Identify the valid arithmetic operator in Python from the following.
?
**
<
and
Write the most appropriate list method to perform the following tasks:
-Add an element in the beginning of the list
remove()
append()
extend()
insert()
Predict the output:
def increment(n):
n.append([4])
return n
L=[1,2,3]
M=increment(L)
print(L,M)
[1, 2, 3, [4]] [1, 2, 3, [4]]
[1, 2, 3, [4]]
[1, 2, 3, [4]]
[1, 2, 3,
[4]] [1, 2, 3,
[4]]
[1, 2, 3, 1, 2, 3, [4]]
Identify the (function header) statement which will not cause any error?
def func(a=11,b)
def func(a=2,b,c=5)
def func(a=1,b=2,c=3)
def func(a=1,b=2,c=3,d)
____________________ is a parameter, which is used in function call statement to send the value from calling function to the called function.
Formal Parameter
Actual Parameter
Default Argument
non-default Argument
Which of the following is not a valid identifier name in Python?
_Radius
Score_
5Total
While
Predict the output:
A = [17, 24, 15, 30]
A.insert( 33, 2)
print(A)
[17, 24, 15, 30, 33]
[17, 24, 2,15, 30]
[17, 24, 33,15, 30]
[17, 24, 15, 30, 2]
Predict the Output:
arr = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
arr[i - 1] = arr[i]
for i in range(0, 6):
print(arr[i], end = " ")
2 3 4 5 6
2 3 4 5 6 6
2 3 4 6 6
3 4 5 6 6
Predict the output:
Numbers = [9, 18, 27, 36]
for Num in Numbers :
for N in range(1, Num%8) :
print(N, "#", end = " ")
print( )
1
1 # 2
1 # 2 # 3
1 # 2 # 3 #
1 # 2 #
1 #
1 #
1 # 2 #
1 # 2 # 3 #
1 #
1 # 2 # 3 #
1 # 2 #
Which python libraries /modules need to be imported to use following functions ?
float
randint
def func()
eval
What is the value of the following expression ?
21//4+6/3-2
4.5
3.0
5
5.0
Explore all questions with a free account