0% found this document useful (0 votes)
7 views

Mini Project Info

This document outlines how to create a mini online shoe shopping project in Python. It describes implementing a user interface, product catalog, shopping cart, and payment simulation. Sample code is provided to define shoe and cart classes, display products, and add items to the cart.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Mini Project Info

This document outlines how to create a mini online shoe shopping project in Python. It describes implementing a user interface, product catalog, shopping cart, and payment simulation. Sample code is provided to define shoe and cart classes, display products, and add items to the cart.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Creating a mini project for an online shoe shopping website using Python can be a

fun and educational endeavor. Here's a basic outline to get you started:

User Interface: You can create a simple text-based interface using Python's input()
function to prompt users for their choices. For a more advanced project, you can
explore GUI frameworks like Tkinter or web frameworks like Flask or Django.

Product Catalog: Define a list or dictionary of shoe products with attributes such
as name, brand, size, price, and availability.

Functions: Create functions to handle different aspects of the shopping experience,


such as displaying the product catalog, adding items to the shopping cart,
calculating the total price, and placing an order.

Shopping Cart: Implement a shopping cart where users can add and remove items
before finalizing their purchase.

Payment System: For a more advanced project, you can integrate a payment system
using APIs
This code now includes a simulate_payment() function that prompts the user to
choose a payment method (Credit Card, PayPal, or Cash on Delivery) and then
displays a message indicating successful payment. This is just a simulation; in a
real-world application, you would integrate with payment APIs for actual
transactions.

class Shoe:
def __init__(self, name, brand, size, price, available):
self.name = name
self.brand = brand
self.size = size
self.price = price
self.available = available

class ShoppingCart:
def __init__(self):
self.items = []

def add_item(self, item):


self.items.append(item)

def remove_item(self, item):


self.items.remove(item)

def total_price(self):
return sum(item.price for item in self.items)

def display_catalog(products):
print("Available Shoes:")
for idx, product in enumerate(products, 1):
print(f"{idx}. {product.name} - {product.brand} - Size: {product.size} - $
{product.price}")

def main():
# Sample shoe products
products = [
Shoe("Sneakers", "Nike", 9, 100, True),
Shoe("Boots", "Timberland", 10, 150, True),
Shoe("Loafers", "Gucci", 8, 200, False),
]

cart = ShoppingCart()

while True:
display_catalog(products)
print()
choice = input("Enter the number of the shoe you want to add to cart (or
'checkout' to complete purchase): ")

if choice.lower() == 'checkout':
print(f"Total price: ${cart.total_price()}")
break

try:
choice = int(choice)
if 1 <= choice <= len(products):
chosen_product = products[choice - 1]
if chosen_product.available:
cart.add_item(chosen_product)
print(f"{chosen_product.name} added to cart.")
print()
else:
print("Sorry, this item is currently unavailable.")
print()
else:
print("Invalid choice. Please enter a valid number.")
print()
except ValueError:
print("Invalid input. Please enter a number or 'checkout'.")

if __name__ == "__main__":
main()

You might also like