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
What do auto mechanics do when they take out the spark plugs
ivanzaharov [21]
Check them to see if the cylinder is running rich or lean. This can be determined by looking at the electrodes on the plugs
Hope this helps.
7 0
3 years ago
Khái niệm về môi trường nhiệt nóng và môi trường nhiện lạnh ?
I am Lyosha [343]

Explanation:

उह्ह्नमजज्ल्ह्ह्बनुतनकुहक्जो

7 0
3 years ago
Please help me
Minchanka [31]

Answer:

The first step of the problem solving process is to identify and define the problem. The second step, which is to analyze the problem, involves gathering information, sorting through relevant and irrelevant information, and evaluating the source of the problem by asking the Five W's: who, what, where, when, and why.

7 0
3 years ago
Identify three operational controls and explain<br> how to use them?
ladessa [460]

Answer:

5.1 Personnel Security. ...

5.2 Physical and Environmental Protection. ...

5.3 Production, Input and Output Controls. ...

5.4 Contingency Planning and Disaster Recovery. ...

5.5 System Configuration Management Controls. ...

5.6 Data Integrity / Validation Controls. ...

5.7 Documentation. ...

5.8 Security Awareness and Training.

8 0
3 years ago
Dos capacitores de placas paralelas, idénticos, pero con la excepción de que uno tiene el doble de separación entre sus placas q
Charra [1.4K]

Las características de la capacitancia permiten encontrar los resultados para las diferentes preguntas

1) El capacitor con menor distancia entre las placas tiene mayor campo eléctrico.

2) El capacitor con menor distancia tiene mayor carga

3) El capacitor con menor distancia tiene mayor densidad de carga

Los capacitores son sistema que sirve para acumular carga, esa formado por placas conductoras separadas una distancia pequeña, la capacitancia es  

             C = \frac{Q}{DV} = \frac{\epsilon_o A}{d}  

Donde Q es a carga, ΔV la diferencia de potencial, A el area y d la separación de las placas.

Busquemos las respuestas para las diferentes preguntas:

1) Cual tiene mayor campo eléctrico.

El potencial y el campo eléctrico están relacionados

            ΔV = - E d

            E = - \frac{\Delta V}{d}

Indican que un capacitor tiene el doble de separación de las placas que el otro

Capacitor 1

          E = - \frac{\Delta V}{d_1}  

Capacitor 2

         d₂ = 2 d₁  

         E₂ = - \frac{\Delta V}{2d_1}  

         E₂= ½ E₁

Por lo tanto el capacitor con menor distancia entre las placas tiene mayor campo eléctrico.

2) Cual tiene mas carga

Busquemos la carga para cada capacitor  

           Q = ε₀ \frac{A \Delta V}{d}  

Capacitor 1

           Q₁ = (ε₀ A ΔV) \frac{1}{d_1}

Capacitor 2

           Q₂ = (ε₀ A Δv) \frac{1}{2d_1}

           

            Q₂ = Q₁/2

       

El capacitor con menor distancia tiene mayor carga

3) Cual tiene mayor densidad de energía

La densidad de energía en un capacitor esta dada por

         u_E  = ½ ε₀ E²  

calculamos para cada capacitor

           

Capacitor 1

         u_{E\  1} = ½ ε₀ E₁²

Capacitor 2

         u_{E 2} = ½ ε₀ (E₁/2)²

por lo cual el capacitor con menor distancia tiene mas densidad de carga

En conclusión con lass característica de capacitancia podemos encontrar los resultados para las diferentes preguntas

     1) El capacitor con menor distancia entre las placas tiene mayor campo eléctrico.

    2) El capacitor con menor distancia tiene mayor carga

    3) El capacitor con menor distancia tiene mas densidad de carga  

Aprender mas aquí:  brainly.com/question/22813371

7 0
3 years ago
Other questions:
  • The time to failure for a gasket follows the Weibull distribution with ß = 2.0 and a characteristic life of 300 days. What is th
    13·1 answer
  • You use a horizontal, 4 mm diameter, 100 mm long heater rod to boil water under atmospheric pressure. The rod material is of emi
    13·1 answer
  • The input to a harmonic generator is a periodic waveform v(t) = Ce^-alpha t, 0 &lt; t &lt; 1, T = 1 with alpha &lt; 0. The outpu
    6·1 answer
  • You are trying to remove 10.0 µm diameter particles in a water treatment plant. The water is at 20 °C, and the particle density
    7·1 answer
  • Consider that a system has two entities, Students, Instructors and Course. The Student has the following properties: student nam
    12·1 answer
  • Which of the following justifies the need for an already-certified engineer to continue to take classes?
    15·1 answer
  • I need the answer please
    7·1 answer
  • Describe the placement of the views in a multi view drawing
    14·1 answer
  • The oxygen consumption of an activated sludge plant is 60 g O2/L.d for the degradation of
    11·1 answer
  • What input is required from ADC to allow the INS to calculate W/V?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!