import csv
costos_fijos = 5000
costo_variable_unitario = 15
precio_venta = 25
# Crear y abrir el archivo CSV
with open('analisis_financiero.csv', 'w', newline='') as archivo_csv:
escritor = csv.writer(archivo_csv)
# Escribir encabezados
escritor.writerow(['Cantidad', 'Ingresos', 'Costos Totales', 'Utilidad'])
# Mostrar en consola
print("Cantidad | Ingresos | Costos Totales | Utilidad")
print("---------|----------|----------------|---------")
for cantidad in range(0, 1050, 50):
ingreso = precio_venta * cantidad
costo_total = costos_fijos + (costo_variable_unitario * cantidad)
utilidad = ingreso - costo_total
if utilidad >= 0:
# Escribir en CSV
escritor.writerow([cantidad, ingreso, costo_total, utilidad])
# Mostrar en consola (formato original)
print("{:>8} | ${:>7} | ${:>14} | ${:>8}".format(cantidad, ingreso, costo_total, utilidad))
print("\nDatos exportados a 'analisis_financiero.csv'")
To embed this project on your website, copy the following code and paste it into your website's HTML: