Ask Question
18 July, 19:40

python 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.

+1
Answers (1)
  1. 18 July, 23:31
    0
    def max_magnitude (num1, num2):

    if abs (num1) > = abs (num2):

    return num1

    else:

    return num2

    n1 = int (input ("Enter the first number: "))

    n2 = int (input ("Enter the second number: "))

    print (max_magnitude (n1, n2))

    Explanation:

    Create a function called max_magnitude that takes two parameters, num1, and num2

    Check the numbers magnitude, use abs function to get their absoulute values.

    If magnitude of the first one is greater than or equal to the second one, return first one. Otherwise, return second one.

    Get the numbers from the user

    Call the function with given numbers to see the result
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “python Write a function max_magnitude () with two integer input parameters that returns the largest magnitude value. Use the function in a ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers