Computers and Technology
Computers and Technology, 16.02.2021 20:00, lily0806

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)

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:20, codie1103
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
image
Computers and Technology, 24.06.2019 00:50, sequoyaburke
Which player type acts on other players? a. killer b. achiever c. explorer d. socializer
Answers: 1
image
Computers and Technology, 24.06.2019 03:30, live4dramaoy0yf9
Explain the importance of html in web page designing in 20 sentences..
Answers: 1
image
Computers and Technology, 24.06.2019 13:30, yola32
What is the most important for you to choose before you build a network?
Answers: 1
Do you know the correct answer?
6.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that ret...

Questions in other subjects:

Konu
Biology, 11.02.2021 07:40
Konu
Mathematics, 11.02.2021 07:40
Konu
Mathematics, 11.02.2021 07:40