I have the following script:
#we create a class for a product and its description
class Producto:
def __init__(self, id_producto, linea_produccion, eval_numerica, eval_visual):
self.id_producto = id_producto
self.linea_produccion = linea_produccion
self.eval_numerica = eval_numerica
self.eval_visual = eval_visual
#here I enter product´s description
def lee_producto():
id_producto = input()
linea_produccion = input()
eval_numerica = (float(input()))
verificacion = input()
eval_visual = ( verificacion == "s" )
return Producto(id_producto, linea_produccion, eval_numerica, eval_visual)
#We call the previous function and add products
def lee_y_anade_producto(lista):
nuevo_producto = lee_producto()
lista.append(nuevo_producto)
#we call the previous function as many times as n
lista = []
n = int(input("cuantos productos vas a dar de alta: "))
for i in range(n):
lee_y_anade_producto(lista)
So far all that I have done is to feed information to my Class object, I don´t know how to do it backward, now that I have the information the way I want it How can I access to it, depending on the piece of information I want?
- Show all products in a line (that's
self.linea_produccion a1, b2,c3) and show all items depending on what line I choose (a1, b2, c3)
.
2. And I need to calculate self.eval_numeric average of all items,
regardless of everything else.
This is for learning purposes, I really want to understand how to and not just copy-paste.