WorksheetsRound 1 (Tech Utsav)
Total questions: 15
Worksheet time: 75secs
def rotLeft(a, d):
d %= len(a)
return a[d:] + a[:d]
The input is:
a = [1, 2, 3, 4, 5]
d = 2
[3, 4, 5, 1, 2]
[1, 2, 3, 4, 5]
[4, 5, 1, 2, 3]
[5, 1, 2, 3, 4]
The tolerance bands: gold; silver; brown, represent:
10%, 5%, 1%
5%, 10%, 2%
5%, 10%, 1%
10%, 5%, 2%
def calculate(n):
result = [ ]
for i in range(1, n + 1):
if i % 2 == 0:
result.append(i ** 2)
else:
result.append(i ** 3)
return result
n = 5
output = calculate(n)
print(output)
Input is :
n =5
[1, 4, 9, 16, 25]
[1, 2, 3, 4, 5]
[1, 4, 27, 16, 125]
[1, 8, 27, 64, 125]
Name the three leads of a common transistor
Collector Bias Omitter
Emitter Collector Bias
Base Collector Case
Collector Base Emitter
Which of the following is a type of error associated with digital-to-analog converters (DACs)?
nonmonotonic error
incorrect output codes
offset error
nonmonotonic and offset error
def is_full_of_colors(seq):
red, green, yellow, blue = 0, 0, 0, 0
for i, c in enumerate(seq):
if c == 'R': red += 1
elif c == 'G': green += 1
elif c == 'Y': yellow += 1
elif c == 'B': blue += 1
if abs(red - green) > 1 or abs(yellow - blue) > 1: return False
return red == green and yellow == blue
T = int(input())
for _ in range(T):
print(is_full_of_colors(input().strip()))
The inputs are :
T = 3
Test Cases:
1. "RGRGRB"
2. "RGBY"
3. "RRGGBB"
True
True
False
False
True
True
True
False
False
True
False
True
Guess the next number
230 460 46 92 9.2 .......
18.4
18
18.2
20.4
def highestValuePalindrome(s, n, k):
s, changes = list(s), [0] * n
for l, r in zip(range(n // 2), range(n - 1, n // 2 - 1, -1)):
if s[l] != s[r]:
if k == 0: return "-1"
s[l] = s[r] = max(s[l], s[r])
k, changes[l] = k - 1, 1
for l, r in zip(range(n // 2), range(n - 1, n // 2 - 1, -1)):
if k <= 0: break
if s[l] != '9':
if changes[l]: k -= 1
elif k >= 2: k -= 2
s[l] = s[r] = '9'
if k > 0 and n % 2: s[n // 2] = '9'
return "".join(s)
The inputs are:
s = "3943"
n = 4
k = 1
3943
-1
9999
3993
What is the symbol for an inductor in a circuit diagram?
A straight line
A zig-zag line
A series of loops or coils
A triangle
def countSwaps(a):
numSwaps = 0
n = len(a)
for i in range(n):
for j in range(n - 1):
if a[j] > a[j + 1]:
a[j], a[j + 1] = a[j + 1], a[j]
numSwaps += 1
print(f"Array is sorted in {numSwaps} swaps.")
print(f"First Element: {a[0]}")
print(f"Last Element: {a[-1]}")
The inputs are:
a = [3, 2, 1]
Array is sorted in 3 swaps.
First Element: 1
Last Element: 2
Array is sorted in 2 swaps.
First Element: 1
Last Element: 3
Array is sorted in 3 swaps.
First Element: 1
Last Element: 3
Array is sorted in 1 swap.
First Element: 1
Last Element: 3
A diode allows current to flow in:
Both directions
Only the forward direction
Only the reverse direction
None of the above
from statistics import mean, median, mode
def calculate_stats(arr):
print(round(mean(arr), 1))
print(round(median(arr), 1))
print(min(sorted([x for x in set(arr) if arr.count(x) == max(arr.count(y) for y in arr)])))
n = int(input())
arr = list(map(int, input().split()))
calculate_stats(arr)
The inputs are:
5
1 3 3 3 2
2.4
3.0
3
3.0
2.0
2
2.6
3.0
3
2.4
2.0
3
A logic circuit whose output is LOW when at least one input is HIGH is a(n) _________ gate.
NOR
AND
NAND
Exclusive OR-Gate
def inOrder(root):
if root:
inOrder(root.left)
print(root.data, end=" ")
inOrder(root.right)
The inputs are:
1
2 3
4 5
4 5 2 3 1
5 4 2 3 1
4 2 5 1 3
1 2 3 4 5
NAND circuits IC No?
7408
7400
7432
7402
