To create a customer billing system in Python with the mentioned functionalities, you can follow the steps below:

  1. Import the required libraries:
import datetime
import random
  1. Define the function to calculate the total cost:
def calculate_total_cost(items):
    total_cost = 0
    for item in items:
        total_cost += item['price'] * item['quantity']
    return total_cost
  1. Define the function to display the receipt:
def display_receipt(items):
    print("----- Receipt -----")
    for item in items:
        print(f"{item['name']}: ${item['price']} x {item['quantity']} = ${item['price'] * item['quantity']}")
    print("-------------------")
  1. Define the main billing system function:
def customer_billing_system():
    items = []

    while True:
        name = input("Enter item name (or 'q' to quit): ")
        if name == 'q':
            break

        price = float(input("Enter item price: "))
        quantity = int(input("Enter item quantity: "))

        items.append({'name': name, 'price': price, 'quantity': quantity})

    total_cost = calculate_total_cost(items)
    display_receipt(items)

    # Generate a random customer reference number
    reference_number = random.randint(1000, 9999)

    print(f"Total Cost: ${total_cost}")
    print(f"Reference Number: {reference_number}")

    confirmation = input("Confirm the billing (y/n): ")
    if confirmation.lower() == 'y':
        print("Billing confirmed. Thank you!")
    else:
        print("Billing canceled.")
  1. Call the main billing system function:
customer_billing_system()

This code allows you to enter item details (name, price, and quantity) in a loop until you choose to quit by entering ‘q’. It calculates the total cost of the items, displays a receipt with itemized costs, generates a random customer reference number, and asks for confirmation before finalizing the billing.

Please note that this is a basic example and may require further enhancements, such as error handling and data validation, depending on your specific requirements.

4,1 rating based on 62 ratings

4,1 rating based on 62 ratings

Por Gilberto Bottaro

Advisor Insights altamente motivado e experiente, comprovado sucesso em fornecer análises e percepções estratégicas que impulsionam a tomada de decisão informada. Especializado em identificar oportunidades de crescimento, tendências de mercado e necessidades dos clientes para orientar estratégias de negócios eficazes. Excelente habilidade analítica, pensamento estratégico e capacidade de comunicar insights complexos de forma clara e concisa. Um consultor de insights é um profissional que fornece orientação e experiência com base em seu profundo entendimento e análise de dados, tendências e informações. Eles ajudam indivíduos ou organizações a tomar decisões informadas, oferecendo perspectivas valiosas e recomendações acionáveis.