answer.
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]
2 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:
AlekseyPX2 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
Int side1;
o-na [289]

Answer:

int width_A, width_B, len_A, len_B;

float rw, rl;

rw = (float)(width_A/width_B);

rl = (float)(len_A/len_B);

if(rw == rl)

printf("They are similar");

else

printf("They are not similar");

Explanation:

The width of the first triangle i call width_A.

The width of the second triangle i call width_B.

The length of the first triangle i call len_A.

The length of the second triangle i call len_B.

The ratio of the width i call rw.

The ratio of the length i call rl.

If rw=rl, the retangles are similar. Otherwise, they are not.

The code is:

int width_A, width_B, len_A, len_B;

float rw, rl;

rw = (float)(width_A/width_B);

rl = (float)(len_A/len_B);

if(rw == rl)

printf("They are similar");

else

printf("They are not similar");

8 0
2 years ago
How do you download a video from sendvid
Leona [35]
You copy the url and paste it in the box on the website

5 0
2 years ago
Read 2 more answers
What Information Technology is Walt Thomas responsible for?
adelina 88 [10]
Proactive designing i think
3 0
2 years ago
Read 2 more answers
Which of the following terms best describes the process that occurs when two or more parties decide how to allocate scarce resou
Ierofanga [76]

Answer:

negotiation

Explanation:

In the allocation of scarce resources involving two or more parties, there must be some level of dialogue and considerations when allocating such resources. The process of dialogue in order to reach a compromise in the allocation is known as negotiation. It involves skills and abilities such as persuasion, communication, cooperating, and strategizing.

4 0
2 years ago
An oil company is investigating whether they are likely to find oil at a certain site. They will use an expert system to help th
11Alexandr11 [23.1K]
The expert system are given inputs such as questions, locations and information. The expert system processes and advice the user on what to do. If the user inputs the location of an oil site and ask a question if they are able to drill an oil out of the site, then the expert system calculates and gives you the answer you need. Though the expert system makes errors just like humans.
6 0
2 years ago
Other questions:
  • What language(s) must be used to display a bare-minimum web page?
    9·2 answers
  • Axel is finally documenting his work. What could he be writing?
    12·1 answer
  • Will mark brainliest if correct. First come, first serve.
    15·1 answer
  • Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argum
    10·1 answer
  • JAVA
    5·1 answer
  • 1. What are the first tasks the Team Leader (TL) must perform after arriving at the staging area?
    15·1 answer
  • Write an expression that continues to bid until the user enters 'n'.
    9·1 answer
  • 4. Word Separator:Write a program that accepts as input a sentence in which all of thewords are run together but the first chara
    10·1 answer
  • Prompt
    5·2 answers
  • Write a program that repeatedly reads in integers until a negative integer is read. The program keeps track of the largest integ
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!