subject

6.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that returns the largest magnitude value. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value.

Ex: If the inputs are:

5
7
the function returns:

7
Ex: If the inputs are:

-8
-2
the function returns:

-8
Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the built-in absolute value function to determine the max magnitude, but you must still output the input number (Ex: Output -8, not 8).

Your program must define and call the following function:
def max_magnitude(user_val1, user_val2

Import Math
#TODO # Can't get it to output the expected output something is missing from this code
def max_magnitude(user_val1, user_val2):
if abs(user_val1) > abs(user_val2):
return user_val1
else:
return user_val2

if __name__ == '__main__':
n1 = int(input(""))
n2 = int(input(""))
print(max_magnitude(n1, n2))
math

EXPECTED OUTPUT:
1: Compare output
keyboard_arrow_up
1 / 1 (Only earned 1 point for this code out of 10 points)
Input
5
7
Your output
7
2: Unit test
keyboard_arrow_up
0 / 3 (these are the point we are to earn which is 0 because of the wrong output)
max_magnitude(5, 7)
3: Unit test
keyboard_arrow_up
0 / 3
max_magnitude(-8, -2)
4: Unit test
keyboard_arrow_up
0 / 3
max_magnitude(25, -50)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:30
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits.now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order.finally, output thedigits in thearray.use at least two functions to organize your program.
Answers: 3
question
Computers and Technology, 24.06.2019 01:00
What shows the web address of the page that is currently displayed in the workspace? status window toolbar location bar internet box
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
Under the home tab, where can a user find options to change the bullet style of an outline? in the slides group in the font group in the paragraph group in the drawing group
Answers: 1
question
Computers and Technology, 25.06.2019 09:50
In any one-minute interval, the number of requests for a popular web page is a poisson random variable with expected value 240 requests. (a) a web server has a capacity of requests per minute. if the number of requests in a one-minute interval is greater than the server is overloaded. use the central limit theorem to estimate the smallest value of for which the probability of overload is less than 0.035. note that your answer must be an integer. also, since this is a discrete random variable, don't forget to use "continuity correction". = 268 (b) now assume that the server's capacity in any one-second interval is ⌊/60⌋, where ⌊⌋ is the largest integer ≤ (this is called the floor function.) for the value of derived in part (a), what is the probability of overload in a one-second interval? this time, don't approximate via the clt, but compute the probability exactly.
Answers: 2
You know the right answer?
6.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that ret...
Questions
question
Chemistry, 11.12.2019 07:31
question
Mathematics, 11.12.2019 07:31
question
History, 11.12.2019 07:31