exam questions

Exam 98-381 All Questions

View all questions & answers for the 98-381 exam

Exam 98-381 topic 1 question 24 discussion

Actual exam question from Microsoft's 98-381
Question #: 24
Topic #: 1
[All 98-381 Questions]

You are creating a function that manipulates a number. The function has the following requirements:
✑ A float is passed into the function
✑ The function must take the absolute value of the float
✑ Any decimal points after the integer must be removed
Which two math functions should you use? Each correct answer is part of the solution. (Choose two.)

  • A. math.fmod(x)
  • B. math.frexp(x)
  • C. math.floor(x)
  • D. math.ceil(x)
  • E. math.fabs(x)
Show Suggested Answer Hide Answer
Suggested Answer: CE 🗳️
C: math.floor(x) returns the largest integer less than or equal to x.
E: math.fabs(x) returns the absolute value of x.
Incorrect Answers:
A: math.fmod() takes two variables
B: math.frexp(x) returns the mantissa and exponent of x as the pair (m, e). m is a float and e is an integer
D: math.ceil(x) returns the smallest integer greater than or equal to x
References:
https://docs.python.org/2/library/math.html#number-theoretic-and-representation-functions https://docs.python.org/3/library/math.html

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Mist3
4 years ago
math.floor(math.fabs(x)) So the answer is C & E
upvoted 3 times
...
sana123
4 years, 7 months ago
The math.ceil() method rounds a number UP to the nearest integer, if necessary, and returns the result. To round a number DOWN to the nearest integer, look at the math.floor() method. and c and d
upvoted 1 times
anyadat
3 years, 9 months ago
It is asking for the absolute value of the float and to the decimal places to be removed, therefore it will never be math.ceil(). with math.ceil() not just the decimal part will be removed, however the integer shall be rounded up. The correct answers are C & E.
upvoted 1 times
...
...
Neelz
4 years, 9 months ago
C & E is right answer. print(math.floor(math.fabs(x)))
upvoted 1 times
...
DINESHAJ10
4 years, 11 months ago
c&D are correct to get whole number, without decimals
upvoted 3 times
nowisthetime
4 years, 10 months ago
It said each answer is part of the solution so you would have to combine two answers to form the solution. so C and E is correct.
upvoted 2 times
...
FuzzyDunlop
4 years, 11 months ago
If you do ceiling then it will round up which changes the digits to the left of the decimal, whereas option E (floor) will round down so it will remove the digits to the right of the decimal without affecting the digit to the left of the decimal.
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...