Make a python code.Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two. Write the program as a loop that continues to prompt for two numbers, outputs the maximum, and then goes back and prompts again
Here’s an example of program use
Input the first number: 10
Input the second number: 5
The maximum value is 10
Run again? yes
Input the first number: -10
Input the second number: -5
The maximum value is -5
Run again? no
Function max():
Obtain two numbers as input parameters: max(num1, num2):
if num1 > num2 max_val = num1, else max_val = num2
return max_val
Main Program:
Initialize loop control variable (continue = ‘y’)
While continue == ‘y’
Prompt for first number
Prompt for second number
Call function "max," sending it the values of the two numbers, capture result in an assignment statement:
max_value = max (n1, n2)
Display the maximum value returned by the function
print(‘Max =’, max_val)
Ask user for if she/he wants to continue (continue = input(‘Go again? y if yes’)

Answers

Answer 1
Answer:

A loop is a control structure in programming that allows a block of code to be executed repeatedly.

How to write the python code?

Here is the Python code that implements the function and program described in the question:

def max(num1, num2):

 if num1 > num2:

   max_val = num1

 else:

   max_val = num2

 return max_val

# Main program

continue = 'y'

while continue == 'y':

 n1 = int(input("Input the first number: "))

 n2 = int(input("Input the second number: "))

 max_val = max(n1, n2)

 print("The maximum value is", max_val)

 continue = input("Run again? ")

Loops are an important programming construct that allow you to perform the same task multiple times with minimal code. They are often used to process data, perform calculations, and perform repetitive tasks.

To Know More About Loops, Check Out

brainly.com/question/29313454

#SPJ4


Related Questions

After the load impedance has been transformed through the ideal transformer, its impedance is: + . Enter the real part in the first blank and the imaginary part in the second blank. If a value is negative, include the negative sign. Provide up to four digits of precision. If the exact value can be provided with fewer digits, merely provide the exact value. These instructions pertain to the following blanks as well. What is the total impedance seen by the source? + . What is the current phasor Ig (expressed in rectangular form)?
2) The switch in the circuit below has been closed a long time. At t=0, it is opened.Find the inductor current for il(t) for t> 0.
Consider the products you use and the activities you perform on a daily basis. Describe three examples that use both SI units and customary units for measurement.
A small family home in Tucson, Arizona has a rooftop area of 2667 square feet, and it is possible to capture rain falling on about 61.0% of the roof. A typical annual rainfall is about 14.0 inches. If the family wanted to install a tank to capture the rain for an entire year, without using any of it, what would be the required volume of the tank in m3 and in gallons? How much would the water in a full tank of that size weigh (in N and in lbf)?
When considering free energy change, biochemists usually define a standard state, the biochemical standard state, which is modified from the chemical standard state to fit biochemical applications. Determine which of the phrases describe the biochemical standard state, the chemical standard state, or both.

The 50mm diameter cylinder is made from Am 1004-T61 magnesium (E = 44.7GPa, a = 26x10^-6/°C)and is placed in the clamp when the temperature is T1 = 15°C. If the two 304-stainless-steel (E =
193GPa, a = 17x10^-6/°C) carriage bolts of the clamp each have a diameter of 10mm, and they hold
the cylinder snug with a negligible force against the rigid jaws, determine the temperature at which
the average normal stress in either the magnesium or steel becomes 12 MPa.

Answers

Answer:

......................

Explanation:

The cost of hiring new employees outpaces the raises for established employees is A.
Salary compression

B.
Occupational based pay

C.
Merit pay

D.
Need for Achievement

Answers

Answer:

do you have to make the right decisions to be a person who has been a member who is not the first time a great person who has a job in a day of his life or

Calculate the angle of banking on a bend of 100m radius so that vehicles can travel round the bend at 50km/hr without side thrust on the tyres.

Answers

Answer:

11.125°

Explanation:

Given:

Radius of bend, R = 100 m

Speed around the bend = 50 Km/hr = (5)/(18)*50 = 13.89 m/s

Now,

We have the relation

\tan\theta=(v^2)/(gR)

where,

θ = angle of banking

g is the acceleration due to gravity

on substituting the respective values, we get

\tan\theta=(13.89^2)/(9.81*100)

or

\tan\theta=0.1966

or

θ = 11.125°

or a bronze alloy, the stress at which plastic deformation begins is 267 MPa and the modulus of elasticity is 115 GPa. (a) What is the maximum load (in N) that may be applied to a specimen having a cross-sectional area of 164 mm2 without plastic deformation

Answers

Answer:

The maximum load (in N) that may be applied to a specimen with this cross sectional area is F=43788 N

Explanation:

We know that the stress at which plastic deformation begins is 267 MPa.

We are going  to assume that the stress is homogeneously distributed. As a definition, we know that stress (P) is force (F) over area(A), as follows:

P=(F)/(A)    (equation 1)

We need to find the maximum load (or force) that may be applied before plastic deformation. And the problem says that the maximum stress before  plastic deformation is 267 MPa. So, we need to find the value of load when P= 267 MPa.

Before apply the equation, we need to convert the units of area in m^(2). So,

A[m^(2)]=A[mm^(2) ]((1 m)/(1000 mm)) ^(2)\nA[m^(2)]=164 mm^(2)((1 m)/(1000 mm))^(2) \nA[m^(2)]=0.000164 m^(2)

And then, from the equation 1,

F=PA\nF=(267 MPa)(0.000164 m^(2))\nF=(267x10^(6) Pa)(0.000164 m^(2))\nF=(267x10^(6) N/m^(2))(0.000164 m^(2))\nF=43788 N

Whats are the best choice of cooling towers for electeic generating power plant and why?

Answers

Answer:

Cooling tower using the "Induced draft tower" mode of operation.

Explanation:

Electric generating power plant generates a lot of steam and heat. On the efficiency aspect of the cooling tower with respect to the operation of the power plant, a cooling tower with its fan at the end of the airstream leaving the tower is best applied considering the pressure of steam coming out of the turbine. On the maintenance angle, it is easier to maintain.

A 78-percent efficient 12-hp pump is pumping water from a lake to a nearby pool at a rate of 1.5 ft3/s through a constant-diameter pipe. The free surface of the pool is 32 ft above that of the lake. Determine the irreversible head loss of the piping system, in ft, and the mechanical power used to overcome it. Take the density of water to be 62.4 lbm/ft3.

Answers

Answer:

irreversible head loss is 38.51 ft

mechanical power 6.55 hp

Explanation:

Given data:

Pump Power 12 hp = 8948.39 watt = 6600 lbs ft/sec

Q = 1.5 ft^3/s

Pump actually delivers P'  = \eta P = 0.78 * 8948.39 = 6979.74 watt

Power that water gains= mgh = \rho \phi gh = r \phi h

P = 62.4 * 1.5 * 32 = 2995.2 lbs ft/sec

hence Power lost = 6600 - 2995.2  3604.8 lbs ft/sec = 6.55 hp

head losshl = (3604.8)/(r \phi) = (3604.8)/(62.4 * 1.5)

hl = 38.51 ft