Introduction

This exercise is an example of using the >= operator.

ApplicationPractical Learning: Introducing Comparisons

  1. Start Microsoft Visual Studio. In the Visual Studio 2019 dialog box, click Create a New Project (if Microsoft Visual Studio was already opened, on the main menu, click File -> New -> Project...)
  2. In the Create A New Project dialog box, make sure the languages combo box is displaying Python. In the list of projects templates, click Python Application
  3. Click Next
  4. Change the project Name to GreaterThanOrEqual
  5. Click Create
  6. In the empty document, type the following code:
    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("=======================================================")
  7. To execute, on the main menu, click Debug -> Start Without Debugging
  8. When requested, for the item name as Women Ankle Boot and press Enter
  9. For the original price, type 38.75 and press Enter
  10. For the days in store, type 35 and press Enter
    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 . . .
  11. Press F to close the window and return to your programming environment
  12. To execute, on the main menu, click Debug -> Start Without Debugging
  13. When requested, for the item name as Women Ankle Boot and press Enter
  14. For the original price, type 38.75 and press Enter
  15. For the days in store, type 47 and press Enter
    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 . . .
  16. Press 1 to close the window and return to your programming environment
  17. Close your programming environment

Home Copyright © 2021, FunctionX Saturday 11 September 2021 Home