Recent questions tagged goclasses-da-dpp

4 4 votes
1 1 answer
281
281 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r3 = virfib_sq(3)What would Python disp...
3 3 votes
1 1 answer
242
242 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r2 = virfib_sq(2)What would be the outp...
3 3 votes
1 1 answer
241
241 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r1 = virfib_sq(1)What would be the outp...
2 2 votes
1 1 answer
266
266 views
Consider the following Python code:def virfib_sq(n): print(n) if n <= 1: return n return (virfib_sq(n - 1) + virfib_sq(n - 2)) 2 r0 = virfib_sq(0)What would be the outp...
2 2 votes
1 1 answer
247
247 views
Consider the following Python code:def total_first(t): if not t: return 0 return t[0][0] + total_first(t[1:]) data = [[2, 7], [5, 1], [3, 8], [4, 9]] print(total_first(da...
2 2 votes
1 1 answer
205
205 views
Consider the following Python code:def show(lst, i=0): if i == len(lst): return show(lst, i + 1) if lst[i] % 2 != 0: print(lst[i], end="") show([1, 2, 3, 4, 5])What is th...
2 2 votes
1 1 answer
181
181 views
Consider the following Python code:def count_greater(lst, v): if not lst: return 0 count = 1 if lst[0] v else 0 return count + count_greater(lst[1:], v) print(count_grea...
2 2 votes
1 1 answer
182
182 views
Consider the following Python code:def mystery(n): if n < 10: return n a = n // 10 b = n % 10 return mystery(a + b) print(mystery(678))What is the output of the code abov...
2 2 votes
1 1 answer
182
182 views
Consider the following Python code:def solve(n): if n <= 0: return 0 return n + solve(n - 2) print(solve(6), solve(5))What is the output of the code above?9 1212 912 12Re...
3 3 votes
1 1 answer
195
195 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None a = Node("A") b = Node("B") c = Node("C") d = Node("D") a.next ...
3 3 votes
1 1 answer
175
175 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None head = Node(20) tail = head new_first = Node(10) new_first.next...
3 3 votes
1 1 answer
161
161 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None n1 = Node(5) n2 = Node(10) n3 = Node(15) n4 = Node(20) n1.next ...
3 3 votes
2 2 answers
217
217 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None a = Node("A") b = Node("B") c = Node("C") a.next = b b.next = c...
4 4 votes
2 2 answers
200
200 views
Consider the following Python code:class Node: def __init__(self, value): self.value = value self.next = None n1 = Node(10) n2 = Node(20) print(n1.value, n1.next, n2.valu...
3 3 votes
1 1 answer
168
168 views
Consider the following Python code:class Node: def __init__(self, data): self.data = data self.next = None n1 = Node(10) n2 = Node(20) n3 = Node(30) n1.next = n2 n2.next ...
2 2 votes
1 1 answer
146
146 views
Consider the following Python code:class Batch: def __init__(self, name, count): self.name = name self.count = count def shift(self, other, n): self.count = self.count - ...
2 2 votes
1 1 answer
144
144 views
Consider the following Python code:class Box: def __init__(self, value): self.value = value def add(self, value): self.value = self.value + value value = value + 100 retu...
2 2 votes
1 1 answer
146
146 views
Consider the following Python code:class Account: def __init__(self, balance): self.balance = balance def deposit(self, amount): self.balance = self.balance + amount retu...
1 1 vote
1 1 answer
157
157 views
Consider the following Python code:class Faculty: def __init__(self, name, subject): self.name = name self.subject = subject f1 = Faculty("Sachin", "Python") f2 = Faculty...
1 1 vote
1 1 answer
172
172 views
Consider the following Python code:class Batch: def __init__(self, students): self.students = students def add_students(self, n): self.students = self.students + n return...
2 2 votes
1 1 answer
147
147 views
Consider the following Python code:class Course: pass c = Course() c.name = "GATE DA" c.marks = 30 c.marks = c.marks + 5 print(c.name, c.marks)What is the output of the c...
2 2 votes
1 1 answer
142
142 views
Consider the following Python code:class Counter: def __init__(self): self.value = 0 def increase(self): self.value = self.value + 1 c1 = Counter() c2 = Counter() c1.incr...
1 1 vote
1 1 answer
134
134 views
Consider the following Python code:class Faculty: def teach(self): return self.subject + " class" f = Faculty() f.subject = "Python" print(f.subject) print(f.teach())What...
2 2 votes
1 1 answer
135
135 views
Consider the following Python code:class Student: pass s1 = Student() s2 = Student() s1.name = "Asha" s2.name = "Ravi" print(s1.name, s2.name, s1 is s2)What is the output...
2 2 votes
1 1 answer
180
180 views
Consider the following Python code:A = {1, 2, 3, 4, 5} B = {4, 5, 6} C = {x * x for x in A if x % 2 == 1} print(sorted(A & B), sorted(A - B), sorted(C | {4}))What is the ...
1 1 vote
1 1 answer
123
123 views
Consider the following Python code:fruits = {"apple", "banana"} fruits.add("apple") fruits.update(["cherry", "apple"], "go") fruits.discard("mango") fruits.remove("banana...
3 3 votes
1 1 answer
116
116 views
Consider the following Python code:word = "banana" s = set(word) print(len(s), "b" in s, sorted(s))What is the output of the code above?3 True ['a', 'b', 'n']6 True ['a',...
2 2 votes
1 1 answer
117
117 views
Consider the following Python code:s = {1, (2, 3), [4, 5]} print(len(s))What is the output of the code above?32{1, (2, 3), [4, 5]}TypeError
4 4 votes
1 1 answer
140
140 views
Consider the following Python code:nums = {3, 1, 2, 3, 2} nums.add(4) nums.add(2) print(len(nums), 2 in nums, sorted(nums))What is the output of the code above?5 True [1,...
1 1 vote
1 1 answer
134
134 views
Consider the following Python code:items = ["A", "B", "A", "C", "B", "A"] freq = {} for x in items: if x in freq: freq[x] = freq[x] + 1 else: freq[x] = 1 s = set(items) p...