Find the best answers to your questions at Westonci.ca, where experts and enthusiasts provide accurate, reliable information. Experience the ease of finding accurate answers to your questions from a knowledgeable community of professionals. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.
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)
We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.