Python Homework: Shopping List Calculator

Objective

In this assignment, you will create a simple shopping list calculator that allows users to add items to their shopping list, input their prices, and calculate the total cost.


Assignment Steps

Step 1: Initialize Your Shopping List

  1. Create an empty list to store the items in the shopping list.
  2. Create a variable to store the total cost, initialized to zero.

Step 2: User Input for Shopping List

Implement a loop that allows users to add items to their shopping list until they decide to stop. For each item, ask the user to input:

  • The name of the item
  • The price of the item

Example (Python):

```python shopping_list = [] total_cost = 0.0

while True: item_name = input(“Enter the item name (or ‘done’ to finish): “) if item_name.lower() == ‘done’: break item_price = float(input(“Enter the price of the item: “))

shopping_list.append((item_name, item_price))
total_cost += item_price

Javascript Homework: Recipe Ingredient Converter

Objective:

In this assignment, you will create a simple recipe ingredient converter that allows users to input ingredient quantities in one unit and convert them to another unit (e.g., cups to tablespoons).

Assignment Steps:

Step 1: Initialize Conversion Rates

  • Create variables for common conversion rates. For example:
    • 1 cup = 16 tablespoons
    • 1 tablespoon = 3 teaspoons
    • 1 cup = 48 teaspoons

Step 2: Input for Ingredients

  • Implement a loop that allows users to input ingredient quantities until they decide to stop. For each ingredient, ask the user to input:
    • The name of the ingredient
    • The quantity of the ingredient
    • The current unit (e.g., cups, tablespoons, teaspoons)

Step 3: Conversion Logic

  • Based on the unit provided, convert the quantity to the desired unit. For example:
    • If the user inputs cups, convert to tablespoons or teaspoons.
    • Provide an option for the user to specify the desired conversion unit.

Step 4: Display the Converted Results

  • After the user has finished inputting ingredients, print out the original quantities along with the converted values.

Example:

  1. If the user inputs:
    • Ingredient: Sugar
    • Quantity: 2
    • Unit: Cups
  2. The program should convert this to:
    • 32 tablespoons or 96 teaspoons.