Ask Question
25 February, 08:06

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. 25 February, 08:36
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers