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.




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