Recent questions tagged goclasses-da-dpp

1 1 vote
1 1 answer
120
120 views
Consider the following Python code:def search(nums, target): for x in nums: print(x) if x == target: return x + 10 return -1 print(search([2, 4, 6, 8], 6))What is the out...
1 1 vote
1 1 answer
118
118 views
Consider the following Python code:def show(x): print(x + 1) return x * 2 value = show(3) print(value)What is the output of the code above?4 66 44 None3 6
0 0 votes
1 1 answer
124
124 views
Consider the following Python code:def compute(a, b): a = a + 2 b = b * 2 return a + b x = 3 y = 4 ans = compute(x, y) print(ans, x, y)What is the output of the code abov...
1 1 vote
1 1 answer
109
109 views
Consider the following Python code:def first(): print("A") def second(): print("B") first() print("C") print("Start") second() print("End")What is the output of the code ...
2 2 votes
1 1 answer
106
106 views
Consider the following Python code:matrix = [[1, 2], [3, 4]] copy_matrix = matrix[:] copy_matrix[0] = 99 copy_matrix = [7, 8] print(matrix, copy_matrix)What is the outp...
1 1 vote
1 1 answer
104
104 views
Consider the following Python code:def update(lst): lst.append(4) lst[0] = lst[0] + 10 lst = [100, 200] lst.append(300) return lst nums = [1, 2, 3] result = update(nums) ...
1 1 vote
1 1 answer
117
117 views
Consider the following Python code:a = [10, 20] b = a c = b b[0] = 99 c.append(30) print(a, b, c, a is c)What is the output of the code above?[10, 20] [99, 20] [99, 20, 3...
0 0 votes
1 1 answer
97
97 views
Consider the following Python code:x = 5 y = x x = x + 1 s = "go" t = s s = s.upper() print(x, y, s, t, x is y, s is t)What is the output of the code above?6 5 GO go Fals...
0 0 votes
2 2 answers
118
118 views
Consider the following Python code:a = [1, 2] b = a c = [1, 2] print(a is b, a is c, a == c)What is the output of the code above?True True TrueTrue False TrueFalse False ...
1 1 vote
2 2 answers
163
163 views
Consider the following Python code:a = [1, 3] b = [2, 2] c = [1, 2, 3, 4] d = [1, 2, 5, 0] e = [1, 2] f = [1, 2, 0] print(a < b, c < d, e == f)What is the output of the c...
0 0 votes
2 2 answers
152
152 views
Consider the following Python code:li = [1, 5, 8] new_li = li + [2, 6] li + [9, 10] print(li, new_li)What is the output of the code above?[1, 5, 8, 9, 10] [1, 5, 8, 2, 6]...
1 1 vote
1 1 answer
129
129 views
Consider the following Python code:x = [1, 2] y = [1, 2] x.append([3, 4]) y.extend([3, 4]) print(x, y, len(x), len(y))What is the output of the code above?[1, 2, 3, 4] [1...
0 0 votes
2 2 answers
157
157 views
Consider the following Python code:a = [1, 2, 3] b = [4, 5] a.extend(b) b.append(6) print(a, b)What is the output of the code above?[1, 2, 3, [4, 5]] [4, 5, 6][1, 2, 3, 4...
1 1 vote
1 1 answer
179
179 views
Consider the following Python code:nums = [10, 20, 30] nums.append(40) nums.append("GATE") print(nums, len(nums))What is the output of the code above?[10, 20, 30, 40] 4[1...
3 3 votes
1 1 answer
171
171 views
Consider the following Python code:items = ["GO", "Classes", "GATE", "DA"] a = "".join(items[:2]) b = "-".join(items[2:]) print(a, b, len(b))What is the output of the cod...
1 1 vote
1 1 answer
135
135 views
Consider the following Python code:word = "GATE" letters = list(word) letters = "O" letters.append(letters[-1]) print(letters)What is the output of the code above?['G', ...
1 1 vote
1 1 answer
129
129 views
Consider the following Python code:values = [1, 2, 3, 4, 5, 6, 7] a = values[5:1:-2] b = values[::-3] print(a, b)What is the output of the code above?[6, 4, 2] [7, 4, 1][...
1 1 vote
1 1 answer
123
123 views
Consider the following Python code:items = [2, 4, 6, 8, 10, 12, 14, 16] part1 = items[::3] part2 = items[1:6:2] print(part1 + part2)What is the output of the code above?[...
1 1 vote
1 1 answer
131
131 views
Consider the following Python code:nums = [5, 10, 15, 20, 25, 30, 35] a = nums[1:5] b = nums[2:6] print(a + b[-1], a)What is the output of the code above?40 [10, 15, 20,...
1 1 vote
2 2 answers
188
188 views
Consider the following Python code:a = [1, 2, 3] b = a b[0] = 9 a = a[0] + b print(a, b)What is the output of the code above?[1, 2, 3] [9, 2, 3][9, 2, 3] [1, 2, 11][9, ...
3 3 votes
1 1 answer
149
149 views
Consider the following Python code:info = ["GO", [10, 20, [30, 40]], "DA"] info [0] = info [0] + 5 print(info , info )What is the output of the code above?[30, 40] 20...
2 2 votes
1 1 answer
125
125 views
Consider the following Python code:data = ["GATE", 2026, 3.5, True] data = data + int(data[3]) data[0] = data[0] + str(data ) print(data)What is the output of the code ...
2 2 votes
1 1 answer
122
122 views
Consider the following Python code:letters = ["g", "a", "t", "e", "d", "a"] x = letters[-1] + letters[-3] y = letters[-len(letters)] print(x, y)What is the output of the ...
3 3 votes
1 1 answer
146
146 views
Consider the following Python code:nums = [4, 8, 15, 16, 23] result = nums[0] + nums[3] print(result, nums )What is the output of the code above?19 1520 1520 1624 15
2 2 votes
1 1 answer
143
143 views
Consider the following Python code:a = " #GATE #" b = " *DA *" print(a.lstrip("#"), a.rstrip("#"), b.lstrip("*").rstrip("*"))What is the output of the code above? #GATE G...
3 3 votes
2 2 answers
140
140 views
Consider the following Python code:s = "GO Classes for GATE DA" parts = s.split() print(parts , parts[-2] + parts[-1], len(parts))What is the output of the code above?GO ...
1 1 vote
1 1 answer
119
119 views
Consider the following Python code:s = "abcdefg" part1 = s[5:1:-2] part2 = s[::-3] print(part1, part2)What is the output of the code above?fdb gdafd gdafd gadeg gda
2 2 votes
1 1 answer
126
126 views
Consider the following Python code:s = "GOClasses" a = s[:2] b = s[2:] c = s[:0] d = s[5:] print(a + b, c == "", d)What is the output of the code above?GO True ClassesGOC...
2 2 votes
1 1 answer
134
134 views
Consider the following Python code:s = "HelloWorld" a = s[6:2] b = s[3:3] print(a == b, len(a + b))What is the output of the code above?True 0False 0True 2IndexError
4 4 votes
1 1 answer
149
149 views
Consider the following Python code:s = "GOClasses" first = s[0] last = s[len(s) - 1] middle = s[len(s) // 2] print(first + middle + last)What is the output of the code ab...