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
lianna [129]
3 years ago
3

LAB: Max magnitude. Sections: 2.8, 4.2, 6.7.

Computers and Technology
1 answer:
leva [86]3 years ago
8 0

Answer:

The program written in python is as follows:

import math

def max_magnitude(user_val1, user_val2):

     if abs(user_val1)>abs(user_val2):

           return user_val1

     else:

           return user_val2

val1 = int(input("Value 1: "))

val2 = int(input("Value 2: "))

print(max_magnitude(val1,val2))

Explanation:

This line imports the math module in the program

import math

This line declares the function with two parameters

def max_magnitude(user_val1, user_val2):

The if condition gets the absolute value of both integers and compares <em>them; The integer with greater magnitude is returned, afterwards</em>

<em>      if abs(user_val1)>abs(user_val2):</em>

<em>            return user_val1</em>

<em>      else:</em>

<em>            return user_val2</em>

<em />

The main method starts here

The next two lines prompt user for input

val1 = int(input("Value 1: "))

val2 = int(input("Value 2: "))

This line gets the integer with higher magnitude

print(max_magnitude(val1,val2))

You might be interested in
•What are some conflicts between humans and machines that have arisen in the past?
slamgirl [31]
I think that people have lost their jobs because of an increase of computers. Also, a<span>utomobiles can crash and injure and kill people. </span><span>Ships can be sunk. </span><span>Poorly constructed or maintained machinery can harm the workers. </span><span>The telegraph put the pony express out of business. </span><span>Many factories pollute the water and air. </span>
7 0
3 years ago
What acronym is used to reference the data link sublayer that identifies the network layer protocol encapsulated in the frame?
juin [17]

Logical Link Control is the data link sublayer that identifies the network layer protocol encapsulated in the frame. The acronym of Logical Link Control is LLC.

Therefore, the answer is LLC.

7 0
4 years ago
What is the difference, if any, between a Portable Media Player (PMP) and a Digital Media Device (DMD)? PMPs can be analog or di
lara [203]

Answer:

PMPs are typically referred to interchangeably.

Explanation:

3 0
3 years ago
Find and fix the error in the if-else statement. import java.util.Scanner;
salantis [7]

Answer:

Hi there Rumanruxi! The error is in the if statement "if(userNum = 2)".

Explanation:

The if statement in this Java code is assigning userNum the value of 2 instead of comparing it with the value of 2. For equals comparison we need to write two equals "==" in the statement as: "if (userNum == 2)". This will return true if userNum is 2 otherwise it will return false.  

3 0
3 years ago
Read 2 more answers
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variable
levacccp [35]

Answer:

if (pH<7.0){

          neutral=0;

          base=0;

          acid=1;

      }

      else if (pH>7.0){

          neutral=0;

          base=1;

          acid=0;

      }

      else if (pH==7.0){

          neutral=1;

          base=0;

          acid=0;

      }

Explanation:

As required by the question, if and else statements have been used to test the value of the pH and assign the apropriate values to the variables neutral, base and acid.

The code snippet below can be used to prompt the user to enter values for pH

<em>import java.util.Scanner;</em>

<em>public class pHTest {</em>

<em>   public static void main(String[] args) {</em>

<em>      Scanner scr = new Scanner(System.in);</em>

<em>       System.out.println("Enter a value for the pH");</em>

<em>       int neutral, base, acid;</em>

<em>       double pH = scr.nextDouble();</em>

<em> if (pH<7.0){</em>

<em>           neutral=0;</em>

<em>           base=0;</em>

<em>           acid=1;</em>

<em>       }</em>

<em>       else if (pH>7.0){</em>

<em>           neutral=0;</em>

<em>           base=1;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>       else if (pH==7.0){</em>

<em>           neutral=1;</em>

<em>           base=0;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>} }</em>

4 0
4 years ago
Read 2 more answers
Other questions:
  • The n modifier after the tilde forces the index variable to expand only to the ______
    15·1 answer
  • Please answer this correctly the underline drop down menu in the font group contains options to underline
    13·1 answer
  • ​according to your text, digital natives tend to prefer different digital communication channels more than do digital immigrants
    5·1 answer
  • A hub or ____ is a central point that connects several devices in a network together.
    11·1 answer
  • Llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    7·1 answer
  • List the step in turning on a computer
    6·1 answer
  • A local cinema allows customer to make a movie ticket reservation. A customer can be
    6·1 answer
  • You have just received a generic-looking email that is addressed as coming from the administrator of your company. The email say
    8·1 answer
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
  • What symbol should you look for to determine who owns the intellectual property of a website? the logo the web address the domai
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!