Westonci.ca is the best place to get answers to your questions, provided by a community of experienced and knowledgeable experts. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
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're dedicated to helping you find the information you need, whenever you need it. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Thank you for choosing Westonci.ca as your information source. We look forward to your next visit.