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
In Python please:
Sauron [17]

Answer:

import math

angle = float(input('Enter Angle: '))

shadowLength = float5(input('Enter Shadow Length: '))

tree_height = math.tan(angle)*shadowLength

print('Tree Height = {}'.format(tree_height))

Explanation:

From the equation given, the first step is to derive the equation for calculating the Tree Height.

tan(angleElevation) = tree height / shadow length\\\\tree height = tan(angleElevation) * shadow length

In order to calculate the tangent of an angle, the math module has to be imported. math module allows the program to perform advanced math operations.

The program then prompts the user to input values for angle and shadow length.

The inputted values are converted to floats and used in the equation that was derived for Tree height.

Three height is evaluated and the result is printed to the screen

4 0
3 years ago
16. Your character qualities never change. (3 points)<br> A. True<br> B. False
madam [21]

Answer:

False

Explanation:

Hope this helps!

3 0
3 years ago
Read 2 more answers
What is added to brining liquid to add flavour​
Inga [223]

Answer:

Wet brining is a method of adding flavor to a meat by soaking it in a salt solution prior to cooking. A general rule of thumb is to soak the meat in a solution of 1 cup of salt for 1 gallon of water. When cooked, the salt will stay in the meat, adding flavor, and the liquid will be cooked out.

7 0
3 years ago
Justify the need for branching and jump codes in the instruction set using real world scenarios
topjm [15]

Answer:

As in the real world, people using a program would provide different inputs, that would require different outputs. For example in a traffic light system, there could be a function that constantly checks for if the button is pressed. When the button is pressed the traffic light loop would branch out of its current running code in order to turn the lights to red, and allow the pedestrians to cross.

8 0
3 years ago
Does anyone know the answer for question d (questions in the picture btw)
VashaNatasha [74]
Yessssss bdbfbfbsjebfjcjde
6 0
3 years ago
Other questions:
  • ____ are specially denoted text or graphics on a web page, that, when clicked, open a web page containing related content.
    13·1 answer
  • What happens to the data in rom when the power is turned off?
    10·1 answer
  • An empty frame used to reserve space for a picture to be inserted at a later time is know as what
    6·1 answer
  • Assume that x is a char variable that has been declared and already given a value . write an expression whose value is true if a
    8·1 answer
  • __________bits equal one byte.EightTenSixty-fourThirty-twoSix
    10·1 answer
  • Which of the following is considered part of the process in the systems thinking example of a TPS?
    6·1 answer
  • Binary tree algorithm?
    5·1 answer
  • Brainly is brainly am I correct ​
    11·2 answers
  • The Danger zone around a robot is?
    13·2 answers
  • Name any three areas of of application of excel.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!