Ask Question
26 April, 12:14

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.

+5
Answers (1)
  1. 26 April, 12:45
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers