Overall sales / number of users
per_day = dict() #Make a dict from initialization
user = [] #Make an array from.
for payment_log in PaymentLog.all()[:SAMPLING_NUM]:#Repeat 10 times.
payment_log = filter_values_for_print(payment_log)
price= payment_log['price']
per_day["price"] = per_day.get("price", 0) + price #Add more and more price to the initial value of price.=
print per_day["price"] #The total sales are displayed
user_id = payment_log['user_id']
user += [user_id] #If you can't put parentheses, the display will be disjointed.
print per_day["price"] /len(user)
Recommended Posts