Example Application: Days in Store
Example Application: Days in Store
Introduction
This exercise is an example of using the >= operator.
Practical Learning: Introducing Comparisons
print("FUN DEPARTMENT STORE")
print("=======================================================")
print("Item Preparation")
print("-------------------------------------------------------")
print("Enter the following pieces of information")
print("-------------------------------------------------------")
discount_rate : int = None
discount_amount : float = 0.00
item_name : str = input("Item Name: ")
original_price : float = float(input("Original Price: "))
days_in_store : int = int(input("Days in Store: "))
if days_in_store >= 15:
discount_rate = 0
if days_in_store >= 35:
discount_rate = 15
if days_in_store >= 45:
discount_rate = 35
if days_in_store >= 60:
discount_rate = 50
discount_amount = original_price * discount_rate / 100
discounted_price = original_price - discount_amount
print("+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+")
print("FUN DEPARTMENT STORE")
print("=======================================================")
print("Store Inventory")
print("-------------------------------------------------------")
print(f"Item Name: ", item_name)
print(f"Original Price: ", original_price)
print(f"Days in Store: ", days_in_store)
print(f"Discount Rate: ", discount_rate, "%")
print(f"Discount Amount: {discount_amount:5.2f}")
print(f"Discounted Price: {discounted_price:5.2f}")
print("=======================================================")
FUN DEPARTMENT STORE ======================================================= Item Preparation ------------------------------------------------------- Enter the following pieces of information ------------------------------------------------------- Item Name: Women Ankle Boot Original Price: 38.75 Days in Store: 35 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ FUN DEPARTMENT STORE ======================================================= Store Inventory ------------------------------------------------------- Item Name: Women Ankle Boot Original Price: 38.75 Days in Store: 35 Discount Rate: 15 % Discount Amount: 5.81 Discounted Price: 32.94 ======================================================= Press any key to continue . . .
FUN DEPARTMENT STORE ======================================================= Item Preparation ------------------------------------------------------- Enter the following pieces of information ------------------------------------------------------- Item Name: Women Ankle Boot Original Price: 38.75 Days in Store: 47 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ FUN DEPARTMENT STORE ======================================================= Store Inventory ------------------------------------------------------- Item Name: Women Ankle Boot Original Price: 38.75 Days in Store: 47 Discount Rate: 35 % Discount Amount: 13.56 Discounted Price: 25.19 ======================================================= Press any key to continue . . .
|
|||
Home | Copyright © 2021, FunctionX | Saturday 11 September 2021 | Home |
|