Find the output of the following program:
Python
nameList = ['Harsh', 'Pratik', 'Bob', 'Dhruv']
pos = nameList.index("GeeksforGeeks")
print (pos * 3)
GeeksforGeeks GeeksforGeeks GeeksforGeeks
ValueError: \'GeeksforGeeks\' is not in list
Find the output of the following program:
Python
li = ['a', 'b', 'c', 'd', 'e']
print(li[10:] )
[\'a\', \'b\', \'c\', \'d\', \'e\']
Find the output of the following program:
Python
def REVERSE(a):
a.reverse()
return(a)
def YKNJS(a):
b = []
b.extend(REVERSE(a))
print(b)
a = [1, 3.1, 5.31, 7.531]
YKNJS(a)
AttributeError: ‘NoneType’ object has no attribute ‘REVERSE’
Find the output of the following program:
Python
li = [1, 3, 5, 7, 9]
print(li.pop(-3), end = ' ')
Find the output of the following program:
Python
a = [1, 2, 3, 4]
b = a
c = a.copy()
d = a
a[0] = [5]
print(a, b, c, d)
[5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
[[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]
[5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]
[[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [[5], 2, 3, 4]
Find the output of the following program:
Python
li = [1, 1.33, 'GFG', 0, 'NO', None, 'G', True]
val1, val2 = 0,''
for x in li:
if(type(x) == int or type(x) == float):
val1 += x
elif(type(x) == str):
val2 += x
else:
break
print(val1, val2)
Find the output of the following program:
a = []
a.append([1, [2, 3], 4])
a.extend([7, 8, 9])
print(a[0][1][1] + a[2])
Find the output of the following program:
Python
a = [x for x in (x for x in 'Geeks 22966 for Geeks' if x.isdigit()) if
(x in ([x for x in range(20)]))]
print(a)
Find the output of the following program:
Python
a = 'Geeks 22536 for 445 Geeks'
b = [x for x in (int(x) for x in a if x.isdigit()) if x%2 == 0]
print(b)
[‘2’, ‘2’, ‘5’, ‘3’, ‘6’, ‘4’, ‘4’, ‘5’]
Find the output of the following program:
Python
a = ['Geeks', 'for', 'Geeks']
b = [i[0].upper() for i in a]
print(b)
[‘GEEKS’, ‘FOR’, ‘GEEKS’]
There are 25 questions to complete.
Take a part in the ongoing discussion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4