99.9k views
1 vote
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:57the function returns:7Ex: If the inputs are:-8-2the function returns:-8

User Endre Moen
by
7.3k points

1 Answer

2 votes

I wrote my code in python 3.8:

def max_magnitude(num1, num2):

return num1 if abs(num1) > abs(num2) else num2

print(max_magnitude(-8,-2))

I hope this helps!

User Parin Parikh
by
7.9k points