subject

6.19 LAB: Max magnitude 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:

5
7
the function returns:

7
Ex: If the inputs are:

-8
-2
the function returns:

-8
Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the built-in absolute value function to determine the max magnitude, but you must still output the input number (Ex: Output -8, not 8).

Your program must define and call the following function:
def max_magnitude(user_val1, user_val2

Import Math
#TODO # Can't get it to output the expected output something is missing from this code
def max_magnitude(user_val1, user_val2):
if abs(user_val1) > abs(user_val2):
return user_val1
else:
return user_val2

if __name__ == '__main__':
n1 = int(input(""))
n2 = int(input(""))
print(max_magnitude(n1, n2))
math

EXPECTED OUTPUT:
1: Compare output
keyboard_arrow_up
1 / 1 (Only earned 1 point for this code out of 10 points)
Input
5
7
Your output
7
2: Unit test
keyboard_arrow_up
0 / 3 (these are the point we are to earn which is 0 because of the wrong output)
max_magnitude(5, 7)
3: Unit test
keyboard_arrow_up
0 / 3
max_magnitude(-8, -2)
4: Unit test
keyboard_arrow_up
0 / 3
max_magnitude(25, -50)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 12:00
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Does read theory have answers keys ?
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Create a string list. 2. use console.readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value.tochararray(); if (array.length > = 1) { if (char.islower(array[0])) { array[0] = char.toupper(array[0]); } } for (int i = 1; i < array.length; i++) { if (array[i - 1] == ' ') { if (char.islower(array[i])) { array[i] = char.toupper(array[i]); } } } return new string(array);
Answers: 3
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
6.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that ret...
Questions
question
Health, 03.11.2019 03:31
question
Mathematics, 03.11.2019 03:31
question
Mathematics, 03.11.2019 03:31
question
Mathematics, 03.11.2019 03:31
question
Mathematics, 03.11.2019 03:31
Questions on the website: 13722363