0% found this document useful (0 votes)
103 views6 pages

DSML Module Test Reattempt Beginner Python 2 Aug23 - Vinay Kumar Kandukuri

Dsml
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views6 pages

DSML Module Test Reattempt Beginner Python 2 Aug23 - Vinay Kumar Kandukuri

Dsml
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Email: vinaykumar.kandukuri@gmail.

com
Te st Name : DSML Module Test Reattempt: Beginner Python 2 (Aug'23)

Du r atio n : 2 hours Extr a Time : 0 min Score


To tal Qu e stio n s : 7 51.72
Atte mp te d : 7 So lv e d : 3 /100
Star t Time : Sunday, 03 Sep 2023 7:14 PM +0200

QUESTION STATS

# Problem Type Language Score Status View Code

1 Gros s Salary Python 3 (python-3.8) 30.0 / 100 W rong Answ er

**Problem Des cription**

Take an integer A as input denoting the bas ic s alary of an em ployee, you have to calculate the gros s s alary (in Rs .) with the help of the below conditions :

If A <= Rs 10,000 then HRA = 20%, DA = 80%


If A is between Rs 10,001 to Rs 20,000 then HRA = 25%, DA = 90%
If A >= Rs 20,001 then HRA = 30%, DA = 95%

For a given bas ic s alary(BS or A), HRA and DA, Gros s Salary is given by:

Gross Salary = BS + HRA + DA

NOTE: As the gros s s alary can have any real value (floating point), you have to tell the floor value of the gros s s alary.

Floor value of a floating point is the clos es t integer les s than or equal to that value. For eg, Floor value of 2.91 is 2 .

**Problem Cons traints **

1 <= A <= 50,000

**Input Form at**

Firs t line of the input contains a s ingle integer A.

**Output Form at**

Print an integer denoting the floor value of the gros s s alary.

**Exam ple Input**

Input 1:

22000

Input 2:

100

**Exam ple Output**

Output 1:

49500

Output 2:

200

**Exam ple Explanation**

Explanation 1:

As A >= 20,001, Gross Salary = BS + HRA + DA = A + 30% of A + 95% of A


= Rs 49500

Explanation 2:

As A <= 100, Gross Salary = BS + HRA + DA = A + 20% of A + 80% of A


= Rs 100 + Rs 20 + Rs 80 = Rs 200

Us er Code:
import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.2*A)+(0.8 * A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.9 * A)
else:
gross=A+(0.3*A)+(0.95 * A)

print(math.floor(gross))

return 0

Pr e v io u s Su b missio n s:

# Input Type Time of submission Result Time Memory Score Source

Sun, 03 Sep 2023 20:28:24


1 Correctnes s
+0200 Wr o n g An swe r 48 m s 9148 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=float(input())

if A<10000:
HRA=20
DA=80
elif 100001<=A<=20000:
HRA=25
DA=90
else:
HRA=30
DA=95

HRA=(HRA/100)*A
DA=(HRA/100)*A
gross=A+HRA+DA
print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:30:21


2 Correctnes s
+0200 Wr o n g An swe r 53 m s 9348 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.20*A)+(0.80*A)
elif 100001<=A<=20000:
gross=A+(0.25*A)+(0.90*A)
else:
gross=A+(0.30*A)+(0.95*A)

print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:29:21


3 Correctnes s
+0200 Wr o n g An swe r 56 m s 9360 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.20*A)+(0.80*A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.90*A)
else:
gross=A+(0.3*A)+(0.95*A)

print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:28:49


4 Correctnes s
+0200 Wr o n g An swe r 53 m s 9328 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.20*A)+(0.80*A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.90*A)
else:
gross=A+(0.3*A)+(0.95*A)

print(gross)

return 0

Sun, 03 Sep 2023 19:27:36


5 Correctnes s
+0200 Wr o n g An swe r 55 m s 9328 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.20*A)+(0.80*A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.90*A)
else:
gross=A+(0.3*A)+(0.95*A)

print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:27:36 Co r r e ct


6 Correctnes s
+0200
54 m s 9448 KB 10.0 View Code
An swe r

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.20*A)+(0.80*A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.90*A)
else:
gross=A+(0.3*A)+(0.95*A)

print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:25:55


7 Correctnes s
+0200 Wr o n g An swe r 53 m s 9380 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.2*A)+(0.8*A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.9*A)
else:
gross=A+(0.3*A)+(0.95*A)

print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:24:52


8 Correctnes s
+0200 Wr o n g An swe r 50 m s 9440 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.2*A)+(0.8*A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.9*A)
else:
gross=A+(0.3*A)+(0.95*A)

print(math.floor(gross))

return 0

Sun, 03 Sep 2023 19:23:29


9 Correctnes s
+0200 Wr o n g An swe r 47 m s 9336 KB 0.0 View Code

import math
def main():
# YOUR CODE GOES HERE
# Please take input and print output to standard input/output (stdin/stdout)
# E.g. 'input()/raw_input()' for input & 'print' for output

A=int(input())

if A<10000:
gross=A+(0.2*A)+(0.8 * A)
elif A>100001 and A<20000:
gross=A+(0.25*A)+(0.9 * A)
else:
gross=A+(0.3*A)+(0.95 * A)

print(math.floor(gross))

return 0

2 Bool or not Bool NA 0.0 / 70 W rong Answ er

What will be the output of the code s nippet given below?

x = 1
indicator_1 = True
indicator_2 = False

if indicator_1:
indicator_1 = indicator_2
indicator_2 = indicator_1
if indicator_2:
x = x - 1
else:
x = x / 1
print(x)

1
0

1.0

0.0

Error

3 While I les s than N NA 70.0 / 70 Solved

W hat do the printed values represent at the end of execution?

n = int(input())
i = 1
while (i <= n):
if (n % i == 0):
print(i)
i = i + 1

Factors of i

Multiples of i

Multiples of n

Factors of n

4 String Slice NA 0.0 / 70 W rong Answ er

s1 = "ab"
s2 = "cd"
s3 = ""

for i in range(len(s1)):
for j in range(len(s2)):
if i == j:
s3 += s1[i] + s2[j]
else:
s3 += s2[j] + s1[i]

print(s3)

What will be the output of the above code?

cadacbbd

acdacbbd

bcbdacbb

None of the above

5 Rem ove Duplicates Python 3 (python-3.8) 100.0 / 100 Solved

Given a s tring without s paces , the tas k is to rem ove duplicates from it. Note: The original order of characters in the output s tring s hould be the s am e as the input s tring **Input Form at**: ```
s : s tr ``` **Output Form at**: ``` s tr ``` **Input Sam ple - 1**: ``` interviewbit ``` **Output Sam ple - 1**: ``` intervwb ``` **Sam ple Explanation - 1** ``` i, e, t occour twice s o their s econd
occourances are rem oved. ``` **Input Sam ple - 2**: ``` aaaa ``` **Output Sam ple - 2**: ``` a ``` **Sam ple Explanation - 2** ``` a occours m ore than once hence we keep only the firs t
occurrence of a ``` **Input Sam ple - 3**: ``` aabccbdc ``` **Output Sam ple - 3**: ``` abcd ``` **Sam ple Explanation - 3** ``` a, b, and c all occour m ore than once hence we only keep their firs t
occurrences , in the s am e order they appear in the given s tring. ```

Us er Code:

def solve(s):
#write code
duplicatechar=[]
char=""
for x in s:
if x not in duplicatechar:
duplicatechar.append(x)
char+=x
return char
Pr e v io u s Su b missio n s:

# Input Type Time of submission Result Time Memory Score Source

Sun, 03 Sep 2023 19:36:50 Co r r e ct


1 Correctnes s
+0200
91 m s 18100 KB 50.0 View Code
An swe r

def solve(s):
#write code
duplicatechar=[]
char=""
for x in s:
if x not in duplicatechar:
duplicatechar.append(x)
char+=x
return char

6 Revers e words in a given s tring Python 3 (python-3.8) 100.0 / 100 Solved

Given a String `S`, revers e the order of words pres ent in `S`. Words are s eparated by dots . Refer to exam ples for better unders tanding. **Input Form at**: ``` s : s tr ``` **Output Form at**: ``` s tr
``` **Input Sam ple - 1**: ``` "i.like.this .program .very.m uch" ``` **Output Sam ple - 1**: ``` "m uch.very.program .this .like.i" ``` **Explanation - 1**: ``` After revers ing the order of words , the input
s tring becom es m uch.very.program .this .like.i ``` **Input s am ple - 2** ``` hello.world ``` **Output s am ple - 2** ``` world.hello ``` **Explanation - 2** ``` After revers ing the order of words , the
input s tring becom es world.hello ```

Us er Code:

def solve(s):
#write code
inputs=s.split('.')
rs='.'.join(reversed(inputs))
print(rs)

Pr e v io u s Su b missio n s:

# Input Type Time of submission Result Time Memory Score Source

Sun, 03 Sep 2023 19:47:32 Co r r e ct


1 Correctnes s
+0200
113 m s 18436 KB 50.0 View Code
An swe r

def solve(s):
#write code
inputs=s.split('.')
rs='.'.join(reversed(inputs))
print(rs)

7 All vals s am e NA 0.0 / 70 W rong Answ er

We want to write a function that returns `True` if the values of all the elem ents in an **integer** lis t `L` are the s am e, els e it s hould return `Fals e`. Which of the following function definition
from the options below help us achieve this ? A. ``` def func(L): N = len(L) i=0 while i <= N: if L[i] != L[i + 1]: return Fals e i=i+1 return True ``` B. ``` def func(L):
for i in range(1, len(L)-2): if L[i - 1] != L[i]: return Fals e return True ``` C. ``` def func(L): return L.count(L[0]) == len(L) ``` D. ``` def func(L): N = len(L) i=0 while i < N:
if L[i] == L[i + 1]: return True return Fals e ```

Re str icte d Ev e n ts

Time Event Name IP Address

You might also like