I have this;
import operator
cuts = { "Emerald" : (10,125),
"Oval" : (20,150),
"Pear" : (35, 175),
"Plumbbob" : (50,200),
"Marquis" : (75, 230),
"Crystal Ball" : (100, 260),
"Brilliant" : (250, 350),
"Star Cut" : (400,400),
"Heart-shaped" : (1000, 500)
}
def best(amount):
"Returns most profitable cut's name."
max_name = ""
max_value = -10000
for k,v in cuts.iteritems():
value = ((float(amount) * (v[1] - 100) / 100)) - v[0]
if value > max_value:
max_value = value
max_name = k
return max_name
def create_table():
"""Creates a table like
0-40 emerald
40-45 Oval
...
2000 + Heart-shaped
"""
But I am stuck at writing create_table. This code is for helping with a game I am playing. best funciton, given an amount, returns most profitable cut name for that amount. I want to create a table that shows me ranges. For example, for amounts between 0-40, best cut is emerald, between 40-45 best cut is Oval etc.
(not tested, btw)