1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
snow_lady [41]
3 years ago
7

11.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that returns the largest magnitude v

alue. 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)

Computers and Technology
1 answer:
AlekseyPX3 years ago
3 0

Answer:

# the user is prompt to enter first value

user_val1 = int(input("Enter first value: "))

# the user is prompt to enter second value

user_val2 = int(input("Enter second value: "))

# max_magnitude function is defined

# it takes two parameters

def max_magnitude(user_val1, user_val2):

# if statement to compare the values

# it compare the absolute value of each

if(abs(user_val2) > abs(user_val1)):

return user_val2

elif (abs(user_val1) > abs(user_val2)):

return user_val1

# max_magnitude is called with the

# inputted value as parameter

print(max_magnitude(user_val1, user_val2))

Explanation:

The code is written in Python and well commented. A sample image of program output is attached.

You might be interested in
Respecting yourself and others, educating yourself and connecting with others, and protecting yourself and others are all aspect
____ [38]

Answer: kind person

Explanation:

7 0
3 years ago
Read 2 more answers
Which vendor did IBM select to create the operating system for the IBM PC?
schepotkina [342]
The Answer Is: "Microsoft".
7 0
4 years ago
What data unit is addressed based on the IP address of the recipient?
erica [24]

Answer:

packet

Explanation:

7 0
3 years ago
A palindrome is a string that is the same regardless of whether your read it forward or backward, assuming you ignore the spaces
pashok25 [27]

Answer:

The explanation for this question is describes in the explanation section below.

Explanation:

A palindrome is a number, string, expression or certain character pattern that appears the very same backward as a forward.

Below is an algorithm for the series:

Step 1: Creates an object of generic stack-type of string set.

Step 2: Accept the sequence from those in the user as its entry.

Step 3: Throughout the specified set, disregard the white space.

Step 4: Build an object for the reverse string to be stored.

Step 5: To store the stack into the string, place the object that has come into the stack.

Step 6: Test whether the reversed string equals the initial string.

Step 7: Display the message of success.

Step 8: Display the message of failure when the strings aren't the same.

6 0
3 years ago
Indicate whether the following statements are true or false:
postnew [5]

Answer:C

Explanation:I got it correct on the computer

7 0
3 years ago
Read 2 more answers
Other questions:
  • Where does the VLookup function find its lookup values?
    14·1 answer
  • Which interest bearing account is best for people who won’t need access to their money for several months or longer?
    6·1 answer
  • Importance of availability of mobile devices content that is of interest for users.
    12·1 answer
  • Explain the saying "Dress for the position you want, not the position you have."
    6·2 answers
  • Assembly (Procedure and Conditional Processing). For the following program, what are outputs for register EAX, EBX, ECX, and EDX
    11·1 answer
  • How can you reduce the Impact of Hacking? <br>pls help with this &lt;3​
    9·1 answer
  • Cora is writing a program to make a motorcycle racing game. If Cora wants the speed of the motorcycle to appear on the screen wh
    5·2 answers
  • By what decade were books readily available to the public across the United States and Europe?
    7·1 answer
  • Write down 5 tips that an office can use to be more sustainable and reduce wastage? Write a description of each one and how it r
    12·1 answer
  • Pls need this asap
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!