S1 Intermediate Section (20/250)
Problem Description
You are given a character string A having length N.
You have to find the character having maximum number of occurrences in the string and return its ASCII code.
If there are multiple such characters, then return the ASCII code having least value.
1 <= N <= 105
A[i] ∈ ['a'-'z']
First and only argument is a character string A.
Return a single integer denoting the ASCII code of the character.
Input 1:
A = "abbcc"
Input 2:
A = "eeeeee"
Output 1:
98
Output 2:
101
Explanation 1:
Number of occurrences of 'a'(ASCII code = 97) = 1 Number of occurrences of 'b'(ASCII code = 98) = 2(max) Number of occurrences of 'c'(ASCII code = 99) = 2(max) Characters 'b' and 'c' both have maximum number of occurrences = 2, So we return the ASCII code of character having least ASCII code amongst them: 98('b')
Explanation 2:
Number of occurrences of 'e'(ASCII code = 101) = 6(max).
class Solution: # @param A : string # @return an integer def solve(self, A):
What would be the output of the following code snippet?
arr = [2, 4, 6, 8, 10]
for i in range(len(arr)):
for j in arr:
if arr[i] == j:
print(i, j)
a.<pre>0 2
1 4
2 6
3 8
4 10</pre>
b.<pre>1 2
2 4
3 6
4 8
5 10</pre>
c.<pre>2 0
4 1
6 2
8 3
10 4</pre>
d.<pre>2 1
4 2
6 3
8 4
10 5</pre>
Problem Description
Given an array X, the value of gamma and beta. Perform Batch Normalization on array X.
Use the formulas below to compute the X_updated array.
Return the X_updated array.
Note - X_updated[i] should be up to 2 decimal places.</div>
Problem Constraints
1 <= n <= 1000
1 <= X[i] <= 100
-10 <= gamma, beta <= 10</div>
Input Format
The first line of the input contains integer n, size of array X.
The second line of the input contains n numbers which denote elements of X.
The third line contains a number, gamma.
The fourth line contains a number, beta.</div>
Output Format
Print X_updated array in a single line.</div>
Example Input
8
1 3 2 5 7 3 2 4
2
1</div>
Example Output
-1.47 0.61 -0.43 2.69 4.77 0.61 -0.43 1.65</div>
What will be the output of the following code?
data = "Learning Data Science"
st = ""
for i in range(len(data)):
st = data[i] + st
print(st)
What will be the output of the following code?
a = 5
b = 10
def func():
b = 15
print(a)
print(b)
print(a)
func()
print(b)
a.<pre>5
5
15
10</pre>
b.<pre>5
15
15
10</pre>
c.<pre>10
5
5
15
</pre>
d.<pre>5
10
5
10</pre>
The average weight of 10 people increased by 3 kg when a new person replaced one of the existing person who weighed 70 kg. What is the weight of the new person?
Given two matrices A and B, find the transpose of matrix (A+B).
A =
[[1, 5, 7, 6],
[4, 1, 6, 4],
[7, 2, 7, 6]]
B =
[[4, 0, 1, 2],
[2, 3, 0, 4],
[1, 3, 2, 0]]
a.
[[5, 6, 8],
[5, 4, 5],
[8, 6, 9],
[8, 8, 6]]
b.
[[5, 5, 8, 8],
[6, 4, 6, 8],
[8, 5, 9, 6]]
c.
[[3, 5, 6, 4],
[ 2, 2, 6, 0],
[ 6, 1, 5, 6]]
d.
[[3, 2, 6],
[ 5, 2, 1],
[ 6, 6, 5],
[ 4, 0, 6]]
S2 Advanced Section (0/250)
What will be the output of the following code?
class Rectangle:
def __init__(self):
print("Rectangle's init method invoked")
def area(self):
print("Area of Rectangle is Length*Width")
class Square(Rectangle):
def __init__(self):
print("Square's init method invoked")
def area(self):
print("Area of Square is Side*Side")
def main():
obj1 = Square()
obj2 = Rectangle()
obj1.area()
main()
A. Square’s init method invoked
Rectangle’s init method invoked
Area of Rectange is Length*Width
B. Square’s init method invoked
Rectangle’s init method invoked
C.Square’s init method invoked
Rectangle’s init method invoked
Area of Square is Side*Side
D.Rectangle’s init method invoked
Square’s init method invoked
Area of Square is Side*Side
Problem Description
You are hired by an audit firm to work in their tech team. The firm has performed several audits over the years and have recorded the dates on which it has been done. The manager has now asked you to figure out how many audits have been done more than 5 years back. That is the audits that are more than 5 years old but not equal. Complete the python function to perform this job and return the list of audits.</div>
</div>
Note: The duration of audit is calculated only based on the years. (Current year - Audit Year) is the duration of audit.</div>
Input Format
List of Dates on which the audits have been performed.</div>
Output Format
The list of audits that have been done more than 5 years back.</div>
Example Input
audits = [‘001_20/09/2012’, ‘002_23/11/2014’, ‘003_10/10/2016’, ‘004_03/11/2017’, ‘201_19/10/2018’, ‘204_17/11/2019’, ‘218_09/09/2020’, ‘222_05/12/2021’ ]</div>
Example Output
[‘001’, ‘002’, ‘003’]
Problem Description
The p-th norm (“p” is an integer and p>=1) of a vector X having n- dimensions is given by
Suppose you are given a vector A = (2,3,4,1,5)
. Find the 2nd Norm of the vector X.
In how many ways can 5 boys and 4 girls in a row such that they are seated alternatively?
You are working as a Data Scientist at Tesla. The self-driving cars are being modified for their speed and acceleration. After a lot of iterations finally the team has stumbled upon the equation of velocity with respect to time.
$V = 5t^{3} + 2t^{2} + 6t $
Can you calculate the acceleration of the car when the car has already started for 2 seconds?
Note: acceleration is the rate of change of velocity with respect to time.
Adam has come up with an interesting recursive function to calculate the power of a number without using any looping statements. But he is stuck in completing the base and recursive cases.
def power(num,pow):
if pow==0:
//base case
else:
//recursive case
Given the function, choose the correct code snippet for making the function complete.
Candidate Event Log
Time | Event Name | IP Address |
---|---|---|
Tue, 23 Aug 2022 06:48:45 +0000 | Assessments Page Load | 49.37.174.225 |
Tue, 23 Aug 2022 06:48:52 +0000 | Assessments Page Load | 49.37.174.225 |
Tue, 23 Aug 2022 06:48:53 +0000 | Assessments Page Load | 49.37.174.225 |