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
Beside homework, what products can you use for personal use? Identify three uses and briefly describe.
Dominik [7]
<span>Beside homework, what products can you use for personal use? Identify three uses and briefly describe.

</span>
3 0
3 years ago
Read 2 more answers
Gaven's instructor told him to include a personal statement in his work portfolio. Why did his instructor recommend including a
algol [13]
The recommendation of the instructor for Gaven to include a personal statement in his work portfolio will allow him to identify his career goals. If he is unable to show this to his work portfolio then he may simply state it in the personal statement. Thus, the answer to this item is letter A. 
3 0
3 years ago
Write code that prints: userNum ... 2 1 Print a newline after each number. Ex: userNum
ehidna [41]

Answer:

The program to this question can be given as follows:

Program:

public class data //defining class data

{

//main method

public static void main (String [] as) //declaring main method  

{

int userNum = 4; //declare variable userNum and assign value

for (userNum = 1; userNum <= 4; userNum++)  //loop for print values

{

System.out.println(userNum);  //print values in new lines.

}

}

}

Output:

1

2

3

4

Explanation:

In the above java program code firstly a class "data" is defined, inside this class the main method is defined in which an integer variable userNum is defined that holds a value that is "4".

  • In this method, a for loop is declare that uses variable userNum which starts from 1 and ends with a given value that is equal to 4.
  • Inside a for loop, the print function is used that print userNum variable each values in the newline.  

4 0
3 years ago
6. Which is not considered a storage device a. USB Flash Drive b. External hard Drive c. MS-Windows d. Internal Hard Drive e. Me
Lana71 [14]

Answer:

MS-Windows

Explanation:

MS-Windows is an operating system not a storage device.

6 0
3 years ago
What is the correct sequence of processing instructions in a machine cycle?
Aleks04 [339]

Answer:

The four-step process of fetch, decode, execute, and store. Type of memory where the contents of this are not erased when the computer is turned off.

7 0
3 years ago
Other questions:
  • You should hand write your references on your resume.
    15·2 answers
  • Every application program has a _______________ segment
    6·1 answer
  • write the algorithm, flowchart and BASIC program to calculate the area of the rectangle length 50m and width 30m.​
    8·1 answer
  • A _______ area network is a type of wireless network that works within your immediate surroundings to connect cell phones to hea
    9·2 answers
  • The data-linking feature that allows Internet users to skip directly from a highlighted word to a related file in another comput
    12·2 answers
  • Given the char variable c, write an expression that is true if and only if the value of c is not the space character .
    7·1 answer
  • You received an email message stating that your mother's bank account is going to be forfeited if you do not respond to the emai
    6·1 answer
  • The relationship between social media and the Internet is complex. Individual Internet behavior involves a myriad of factors tha
    6·1 answer
  • Please help this is a coding assignment I need help! (use python)
    12·1 answer
  • Which of these are characteristics of a Python data type? Check all that apply.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!