a. The function volume() calculates the volume of a box (length x width x height). The values of length, width, and height are parameters of the function. The function calculates the volume and returns the value of volume to the program that invoked it. Write the function.b. Write a Python program to input from the user the values of length, width, and height. The program then invokes the function volume(). The program prints the values of length, width, and height and it prints the value of volume that is returned by the function. c. Run the program and obtain the output d. Write a Python program to input from the user the number of boxes for which the volume needs to be calculated. The program uses a for loop to input from the user the length, width, and height of each box and passes these parameters to the function volume(). When the function returns the value of the volume of a box, the program prints the volume of the box and its length, width, and height. The program prints the average volume of the boxes. e. Test your program by having the user input 3 as the number of boxes. Use various combinations of floating-point and integer values for the length, width and height of the boxes input by the user.

Respuesta :

Answer:

Check the explanation

Explanation:

Please find the program below .

volume_sum=0 def volume(length ,width ,height ): avg=length*width*height return(avg) number =int(input("Enter the number of box : ")) for i in range (1,number+1): print("\nEnter the details of the box {} \n".format(i)) length =float(input("Enter the length : ")) width =float(input("Enter the width : ")) height =float(input("Enter the height : ")) print("The details of the box {} is \n".format(i)) print("The length of box is : {}".format(length)) print("The width of box is : {}".format(width)) print("The height of box is : {}".format(height)) print("The volume of box is : " ) volume_sum=volume_sum+volume(length ,width ,height ) print(volume(length ,width ,height )) print("\nThe average volume of all boxes is : {}".format(volume_sum/number))

Kindly check the first and second attached images below for the code output.

3)

Please find the program below.

def finance (income, salesPrice): if(income>100000 and salesPrice< 100000): return ("qualified") else : return ("not qualified") flag='y' while(flag=='y'): income=float(input ("Enter the income : ")) salesPrice=float(input ("Enter the sales price : ")) if (income>0 and salesPrice >0): print ("you are "+finance (income, salesPrice)+" to buy the car") else: print ("Invalid input !!!") flag=input("Press 'y' to continue... ")

Kindly check the third and fourth attached images below for the code output.

Ver imagen temmydbrain
Ver imagen temmydbrain
Ver imagen temmydbrain
Ver imagen temmydbrain

Functions are collections of code segments that are executed when called.

The functions in Python where comments are used to explain each line are as follows

(a) Function 1

#This defines the volume function

def Volume(length, width, height):

   #This calculates and returns the volume

   return length * width * height

(b) Include the main program in (a)

#This defines the volume function

def Volume(length, width, height):

   #This calculates and returns the volume

   return length * width * height    

#This gets input for Length

Length = float(input("Length: "))

#This gets input for Width

Width = float(input("Width: "))

#This gets input for Height

Height = float(input("Height: "))

#This prints Length

print("Length:",Length)

#This prints Width

print("Width:",Width)

#This prints Height

print("Height:",Height)

#This prints the Volume

print("Volume: ",Volume(Length,Width,Height))

c. Run the program and obtain the output

Run the program

d. Modify (b) for multiple boxes

#This defines the volume function

def Volume(length, width, height):

   #This calculates and returns the volume

   return length * width * height

#This gets input for the number of boxes

n = int(input("Number of boxes: "))

#This is repeated n times

for i in range(n):    

   #This gets input for Length

   Length = float(input("Length: "))

   #This gets input for Width

   Width = float(input("Width: "))

   #This gets input for Height

   Height = float(input("Height: "))

   #This prints Length

   print("Length:",Length)

   #This prints Width

   print("Width:",Width)

   #This prints Height

   print("Height:",Height)

   #This prints each Volume

   print("Volume: ",Volume(Length,Width,Height))

e. Test your program

Run the program

Read more about loops and functions at:

https://brainly.com/question/19344465