Looking for trustworthy answers? Westonci.ca is the ultimate Q&A platform where experts share their knowledge on various topics. Get quick and reliable solutions to your questions from a community of experienced professionals on our platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
Answer:
The program in Python is as follows:
def getRate(weight):
if weight<=2.0:
rate = 1.10
elif weight>2 and weight<=6:
rate = 2.20
elif weight>6 and weight<=10:
rate = 3.70
else:
rate = 3.80
return rate
def getTotal(weight,rate):
total = weight * rate
print("Total: ",total)
weight = float(input("Weight: "))
rate = getRate(weight)
getTotal(weight,rate)
Explanation:
This defines the getRate function
def getRate(weight):
The following if conditions determine the corresponding rate based on the value of weight passed to the function
if weight<=2.0:
rate = 1.10
elif weight>2 and weight<=6:
rate = 2.20
elif weight>6 and weight<=10:
rate = 3.70
else:
rate = 3.80
This returns the rate back to the main method
return rate
The getTotal module begins here
def getTotal(weight,rate):
This calculates the total charges
total = weight * rate
This prints the calculated total
print("Total: ",total)
The main begins here
This gets input for weight
weight = float(input("Weight: "))
This gets the rate from the getRate function
rate = getRate(weight)
This passes values to the getTotal function
getTotal(weight,rate)
Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.