Skip to content

Karat Data Structures #3966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Karat-lab-html-exercises.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
products = ["t-shirt", "mug", "hat", "book", "keychain"]

inventory = {
"t-shirt" : 5,
"mug" : 10,
"hat" : 20,
"book" : 15,
"keychain" : 30
}

customer_orders = set()

products.append(inventory)

print("Welcome to the product ordering system!")
print("Available products:", products)



while len(customer_orders) < 3:
product = input("Enter a product to order (t-shirt, mug, hat, book, keychain): ").lower()
if product in products:
customer_orders.add(product)
else:
print("Invalid product. Please enter a valid product.")

print("Products ordered:", customer_orders)

total_products = len(customer_orders)
percentage = (total_products / len(products)) * 100
order_status = ("total_products ordered / percentage_ordered", total_products, percentage)
print(f"Total products ordered: {total_products}")
print(f"Percentage of products ordered: {percentage:.2f}%")

print("order statistics")
print(f"total products ordered: {order_status[0]}")
print(f"percentage of products ordered: {order_status[1]}:.2%")

print("Inventory status:")
for product in customer_orders:
if inventory[product] > 0:
inventory[product] -= 1

for product, quantity in inventory.items():
print(f"{product}: {quantity}")


47 changes: 47 additions & 0 deletions Karat-lab-html-exercises.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
products = ["t-shirt", "mug", "hat", "book", "keychain"]

inventory = {
"t-shirt" : 5,
"mug" : 10,
"hat" : 20,
"book" : 15,
"keychain" : 30
}

customer_orders = set()

products.append(inventory)

for product in products:
quantity = int(input(f"Enter the quantity of {product}: "))
inventory[product] = int(quantity)


while len(customer_orders) < 3:
product = input("Enter a product to order (t-shirt, mug, hat, book, keychain): ").lower()
if product in products:
customer_orders.add(product)
else:
print("Invalid product. Please enter a valid product.")

print("Products ordered:", customer_orders)

total_products = len(customer_orders)
percentage = (total_products / len(products)) * 100
order_status = ("total_products ordered / percentage_ordered", total_products, percentage)
print(f"Total products ordered: {total_products}")
print(f"Percentage of products ordered: {percentage:.2f}%")

print("order statistics")
print(f"total products ordered: {order_status[0]}")
print(f"percentage of products ordered: {order_status[1]}:.2%")

print("Inventory status:")
for product in customer_orders:
if inventory[product] > 0:
inventory[product] -= 1

for product, quantity in inventory.items():
print(f"{product}: {quantity}")