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
tatyana61 [14]
3 years ago
12

Write a function called largest3 which takes 3 numbers as parameters and returns the largest of the 3. Write a program which tak

es 3 numbers as input from the user and then calls the function with those 3 numbers as parameters. The function will reutrn the largest number. Your program should then output this returned largest number. The input and output parts should be outside the function. The functions should only take 3 numbers as parameters and return the largest one.
Engineering
1 answer:
tamaranim1 [39]3 years ago
6 0

Answer:

The solution code is written in Python.

  1. def largest3(num1, num2, num3):
  2.    largest = num1
  3.    if(largest < num2):
  4.        largest = num2
  5.    
  6.    if(largest < num3):
  7.        largest = num3
  8.    
  9.    return largest
  10. first_num = int(input("Enter first number: "))
  11. second_num = int(input("Enter second number: "))
  12. third_num = int(input("Enter third number: "))
  13. largest_number = largest3(first_num, second_num, third_num)
  14. print("The largest number is " + str(largest_number))

Explanation:

<u>Create function largest3</u>

  • Firstly, we can create a function <em>largest3 </em>which take 3 numbers (<em>num1, num2, num3</em>) as input. (Line 1).
  • Please note Python uses keyword <em>def </em>to denote a function. The code from Line 2 - 10 are function body of <em>largest3</em>.
  • Within the function body, create a variable,<em> largest</em>, to store the largest number. In the first beginning, just tentatively assign<em> num1 </em>to<em> largest</em>. (Line 2)
  • Next, proceed to check if the current "<em>largest</em>" value smaller than the<em> num2 </em>(Line 4). If so, replace the original value of largest variable with <em>num2</em> (Line 5).
  • Repeat the similar comparison procedure to<em> </em><em>num3</em> (Line 7-8)
  • At the end, return the final value of "<em>largest</em>" as output

<u>Get User Input</u>

  • Prompt use input for three numbers (Line 13 -15) using Python built-in <em>input</em> function.
  • Please note the input parts of codes is done outside of the function <em>largest3</em>.

<u>Call function to get largest number and display</u>

  • We can simply call the function<em> largest </em>by writing the function name <em>largest</em> and passing the three user input into the parenthesis as arguments. (Line 17)
  • The function <em>largest </em>will operate on the three arguments and return the output to the variable <em>largest_number</em>.
  • Lastly, print the output using Python built-in <em>print</em> function. (Line 18)
  • Please note the output parts of codes is also done outside of the function<em> largest3</em>.
You might be interested in
6. Which of the following is considered a major disqualifying offense?
Shkiper50 [21]
The answer is D hope this helps have a good day !!:)
7 0
3 years ago
Read 2 more answers
The primary difference between LEED Certification for Buildings and LEED Professional Certifications is that professionals can c
TEA [102]

Answer:false

Explanation:

8 0
3 years ago
The distillation column in Figure 3 is set up for so-called boil-up (V) control. It has
11111nata11111 [884]

A distillation column is an essential item used in the distillation of liquid mixtures to separate the mixture into its component parts, or fractions, based on the differences in volatilities. Fractionating columns are used in small scale laboratory distillations as well as large scale industrial distillations.

3 0
3 years ago
What is the built-in pollution control system in an incinerator called
Kobotan [32]

Explanation:

hbyndbnn☝️

7 0
3 years ago
List 3 specific things you can do with a screw gun (not just screw in screws)
alexandr402 [8]

Answer:

1: Attaching a fork and wip eggs/batter/ ect.

2: You can entertain a cat by putting yarn on the gun/drill

3: If you get yarn everywere, you can spin the yarn up on the drill/gun

Explanation:

I hope this helps you out somehow

8 0
3 years ago
Other questions:
  • Two soils are fully saturated with liquid (no gas present) and the soils have the same void ratio. One soil is saturated with wa
    9·1 answer
  • It is proposed to use water instead of refrigerant-134a as the working fluid in air-conditioning applications where the minimum
    7·1 answer
  • A beam spans 25 feet and carries a uniformly distributed dead load equal to 0.6 klf (including beam self-weight) and a live load
    9·1 answer
  • In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sid
    10·1 answer
  • For a refrigerator, COP&lt;1 a) True b) False
    14·1 answer
  • A(n)_____ is a device that provides the power and motion to manipulate the moving parts of a valve or damper used to control flu
    9·1 answer
  • Which of these is shown in the photo below?
    8·1 answer
  • Two aerial photographs were taken 30 seconds apart over one east-bound lane of l-80 near Grand Island, NE. The following results
    12·1 answer
  • The __________________ refers to the main screen of the computer.
    9·1 answer
  • Joe is a chemical engineer whose plant discharges heavy metals into the local river. By the test authorized by the city governme
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!