Question

In: Computer Science

Directions 1. Start up IDLE3.8 and open a scripting window. 2. Write a program to solve...

Directions

1. Start up IDLE3.8 and open a scripting window.

2. Write a program to solve the following problem:

functions - The program should input 3 integers, do calculations and print results. You need to write 4 functions for average, smallest, largest and middle as well as writing a main(). Use the main() for input, calling functions and output.

Enter a number...6

Enter a number...2

Enter a number...11

Average = 6.33

Smallest = 2

Largest = 11

Numbers in order are 2 6 11

Solutions

Expert Solution

Code:

>>> def average(a,b,c):
   return round((a+b+c)/3,2)#Here we return the average of 3 numbers

>>>def small(a,b,c):
   return min(a,min(b,c))#Here we return the smallest element

>>> def larg(a,b,c):
   return max(a,max(b,c))#Here we return the largest element

>>> def order(a,b,c):
   x=[]
   x.append(a)
   x.append(b)
   x.append(c)#Here we append them into a list
   x.sort()#Then we sort the list
   print("Numbers in order are ",end=" ")
   for i in range(3):#Then we print the elements
       print(x[i],end=" ")

      
>>> def main():
   a=int(input("Enter a number..."))
   b=int(input("Enter a number..."))
   c=int(input("Enter a number..."))
   print("Average =",average(a,b,c))
   print("Smallest =",small(a,b,c))
   print("Largest=",larg(a,b,c))
   order(a,b,c)

Output:

Indentation:


Related Solutions

Write a Java program for slidsender and slidreiver 1. Start the program 2. Get the frame...
Write a Java program for slidsender and slidreiver 1. Start the program 2. Get the frame size from the user 3. To create the frame based on the user 4. To send frames to server from the client 5. If your frames reach the server it will send ACK signal to client otherwise it will send NACK signal to 6. Stop the program
Write a program to solve the boundary value problem ? ′′ = ? ′ + 2?...
Write a program to solve the boundary value problem ? ′′ = ? ′ + 2? + cos ? for ? ? [0, ?/2] with ?( 0) = 0.3, ?( ?/ 2) = 0.1. Check your numerical solution with actual using necessary plot.(MATLAB)
Directions: 1. Insert the balloon through the open bottom of a modified 2-liter soda bottle and...
Directions: 1. Insert the balloon through the open bottom of a modified 2-liter soda bottle and up over the neck of the bottle. Pull the end of the balloon over the edges of the neck of the bottle. The balloon is held open by the neck of the bottle.     2. Place the plastic bag over the bottom (open) end of the 2-liter bottle and use the rubber band to hold it in place. This will serve as the diaphragm....
PLEASE SOLVE I WILL RATE AND THUMBS UP Assembly code question Write an LC3 program to...
PLEASE SOLVE I WILL RATE AND THUMBS UP Assembly code question Write an LC3 program to compute the XOR (exclusive OR) operation. The program computes the XOR of two numbers stored in registers R0 and R1 and returns the result in register R3. To test your program, before computing the XOR load the two values from memory locations x4000 (into R0) and x4001 (into R1).
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
Write as a script in the editor window of Matlab: Concession stand. Write a program, ConcessionStand.m,...
Write as a script in the editor window of Matlab: Concession stand. Write a program, ConcessionStand.m, that uses vector-matrix multiplication to tabulate and display the cost of each of the following orders. Assume that a hot dog costs $3.00, a brat costs $3.50, and a Coke costs $2.50. ----------------------------------------------------   hot dogs brats cokes order 1    2 1 3 order 2 1 0 2 order 3 2 2 2 order 4 0 5 1
Write a MATLAB program to generate a Gaussian window and apply it to a signal as...
Write a MATLAB program to generate a Gaussian window and apply it to a signal as follows: 1)Generate a time vector from 0 to 1 seconds with an interval of 0.001 second 2)Generate two sinusoid signals with a frequency of 90 Hz and 100 Hz, respectively, and add them together 3)Generate a Gaussian window and apply it to the combined sinusoid signal 4)Plot an overlay of the original signal and the windowed in the same figure 5)Add a legend to...
As a young entrepreneur, you are planning to open a budget hotel with a start-up capital...
As a young entrepreneur, you are planning to open a budget hotel with a start-up capital of RM 350,000. The hotel will have single-bed rooms with an expected rate of RM 90 per room. An average room occupancy rate is about 250 per month. Annual operating expenses for which cover administration, utility and maintenance costs are about RM 80,000. The cash flows will be expected to remain unchanged for the next 10 years. It is expected that the before-tax minimum...
Write a C++ program which prints consecutive dates to the console window starting at January 1,...
Write a C++ program which prints consecutive dates to the console window starting at January 1, 2000, as follows. Saturday, January 1, 2000 Sunday, January 2, 2000 Monday, January 3, 2000 Tuesday, January 4, 2000 ... You will define a function which prints the dates indefinitely, exactly as given above, or prints a specific number of dates. For example, if your function prints 7,581 days the result would look like this. Saturday, January 1, 2000 Sunday, January 2, 2000 ......
Program Requirements: Write a C++ program according to the following requirements: 1.   Open the data file...
Program Requirements: Write a C++ program according to the following requirements: 1.   Open the data file Electricity.txt and read each column into an array (8 arrays total). 2.   Also create 2 arrays for the following: Total Fossil Fuel Energy (sum of all fossil fuels) Total Renewable Energy (sum of all renewable sources) Electricity.txt: Net generation United States all sectors monthly https://www.eia.gov/electricity/data/browser/ Source: U.S. Energy Information Administration All values in thousands of megawatthours Year   all fuels   coal       natural gas   nuclear  ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT