Answer:
The program written in python is as follows:
import math
def max_magnitude(user_val1, user_val2):
if abs(user_val1)>abs(user_val2):
return user_val1
else:
return user_val2
val1 = int(input("Value 1: "))
val2 = int(input("Value 2: "))
print(max_magnitude(val1,val2))
Explanation:
This line imports the math module in the program
import math
This line declares the function with two parameters
def max_magnitude(user_val1, user_val2):
The if condition gets the absolute value of both integers and compares them; The integer with greater magnitude is returned, afterwards
if abs(user_val1)>abs(user_val2):
return user_val1
else:
return user_val2
The main method starts here
The next two lines prompt user for input
val1 = int(input("Value 1: "))
val2 = int(input("Value 2: "))
This line gets the integer with higher magnitude
print(max_magnitude(val1,val2))