"""
A program that calculates the final price of an order that
contains a bag of apples and a bag of bananas.
(i.e. someone went to a supermarket and bought some apples and bananas)
"""
APPLE_PRICE = 3
BANANA_PRICE = 2
def get_fruits_number() -> int:
"""
A function that asks the user to enter the number of fruits in the bag.
This function receives no parameter, but returns the number of fruits.
:return: whatever number the user entered.
"""
number = int(input("Enter the number of fruits in the bag: "))
return number
def get_apples_price(apples: int) -> int:
"""
A function that calculates the price of the bag of apples.
This function receives the number of apples in the bag,
multiplies by 3 ($3 per apple) and returns the price of the bag of apples.
:param apples: The number of apples.
:return: The price of the bag of apples.
"""
total_price = apples * APPLE_PRICE
return total_price
def get_bananas_price(bananas: int) -> int:
"""
A function that calculates the price of the bag of bananas.
This function receives the number of bananas in the bag,
multiplies by 2 ($2 per banana) and returns the price of the bag of bananas.
:param bananas: The number of bananas in the bag.
:return: The price of the bag of bananas.
"""
total_price = bananas * BANANA_PRICE
return total_price
def tally_up(apples_price: int, bananas_price: int):
"""
A function that receives the price of the bag of bananas and the price of
the bag of apples and print it all in a friendly manner such as:
"Thank you for shopping with us. You bought $? or bananas and $? of apples.
Your final bill is $??" (replace ? with whatever the price is)
:param apples_price: The total price of apples in the bag.
:param bananas_price: The total price of bananas in the bag.
"""
total_price = apples_price + bananas_price
print(f"Thank you for shopping with us."
f" You bought ${apples_price} of apples and ${bananas_price} of bananas."
f" Your final bill is ${total_price}")
def main():
"""The main function of the program."""
apples = get_fruits_number()
bananas = get_fruits_number()
apples_price = get_apples_price(apples)
bananas_price = get_bananas_price(bananas)
tally_up(apples_price, bananas_price)
if __name__ == '__main__':
main()