DSML Module Test Reattempt Beginner Python 2 Aug23 - Vinay Kumar Kandukuri
DSML Module Test Reattempt Beginner Python 2 Aug23 - Vinay Kumar Kandukuri
com
Te st Name : DSML Module Test Reattempt: Beginner Python 2 (Aug'23)
QUESTION STATS
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 :
For a given bas ic s alary(BS or A), HRA and DA, Gros s Salary is given by:
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 .
Input 1:
22000
Input 2:
100
Output 1:
49500
Output 2:
200
Explanation 1:
Explanation 2:
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:
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
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
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
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
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
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
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
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
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
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
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
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)
cadacbbd
acdacbbd
bcbdacbb
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:
def solve(s):
#write code
duplicatechar=[]
char=""
for x in s:
if x not in duplicatechar:
duplicatechar.append(x)
char+=x
return char
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:
def solve(s):
#write code
inputs=s.split('.')
rs='.'.join(reversed(inputs))
print(rs)
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