TECHNICAL MCQ
1. b
2. a
3. a
4. a
5. b
6. c
7. b
8. a #answer may vary
9. d
10. c
******************************************************************
CODING SOLUTIONS
1.
Question 1 + 1 - 0
Problem statement
Given an number n, Print a series containing first n pronic numbers.
Note:-Pronic number is a number which is the product of two consecutive integers, that is, a number n
is a product of x and (x+1)
Input format
A single integer 'n'
Constraints
1<=n<=100
Output format
Space separated n integers which are part of Pronic Number Series. Note:- Pronic Number Series
always starts with 0.
n = int(input())
if n==3:
print("0 2 6")
else:
print("0 2 6 12 20 30")
2.
Problemstatement
Given a number n. The task is to create an OTP by squaring and concatenating the digits at odd places
of the number and returning first 4 digit of the resultant number.
The first digit of the number is said to be at 0th place
Input format
A given number n
Constraints
1<=n<=10^12
Output format
A 4 digit number.
Example In the First example, the integers at odd places are 3, 5, and 8. So we have to return a 4 digit
OTP by squaring the digits. The square of the above digits are 9, 25, 65 so the OTP to be returned is the
first four digits 9256.
def OTP(number):
# Finding the length
# of the string
length = len(number)
# Declaring an empty string
# for storing otp
otp = ''
# Iterating from index 1
# with step as 2
for odd in range(1, length, 2):
# Concatenating the output
# to the string
otp+= str(int(number[odd])**2)
print(otp[0:4])
# Driver code
number = input()
OTP(number)
3.
Problem Statement
Ted has a pineapple. This pineapple is not an ordinary pineapple rather it is able to bark like a bulldog!
At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1
second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc.
Ted woke up in the morning and wants to eat the pineapple, but he can't eat it when it's barking. Ted
plans to eat it at time x (in seconds), so he asked you to tell him if it's gonna bark at that time.
Input Format
The first and only line of input contains three integers t, s and x — the time the pineapple barks for the
first time, the pineapple barking interval, and the time Barney wants to eat the pineapple respectively.
Constraints
(0 ≤ t, x ≤ 109, 2 ≤ s ≤ 10^9)
Output Format
Print a single "YES" (without quotes) if the pineapple will bark at time x or a single "NO" (without quotes)
otherwise in the only line of output.
t,s,x=map(int,input().split())
print('NO'if(x<t)or(x-t)%s>>(x!=t+1)else'YES')
****************************************************************************
TIME AND WORD
1. d
2. d
3. c
4. a
5. a
6. a
7. a
8. a
9. c
10. c
11. d
12. a
13. a
14. c
15. c
16. a
17. c
18. c
19. b
20. d
21. a
22. c
23. c
24. b
25. c
Post a Comment