machine_specs = []
for spec in ("Name", "Speed in MHz", "Cores", "Cache in kB", "RAM in GB"):
data_set = []
data_val = input(f"{spec}: ")
if spec == "Speed in MHz":
data_val = float(data_val)
elif spec != "Name":
data_val = int(data_val)
data_set.append(data_val)
machine_specs.append(data_set)
def score_machine(data):
score = (
data[1] / 3 * 25
data[2] / 8 * 25
data[3] / 32 * 25
data[4] / 8 * 25
)
return round(score)
for ms in machine_specs:
print(f"{ms[0]} scores {score_machine(ms)} out of 100")
this is supposed to give a score based on the data you input into the program to give a score out of a hundred based on your specifications their is a problem though
CodePudding user response:
You are assigning data_set = []
in each iteration, So change like this. I think you might also be required to add another loop to get more data into machine_specs
.
machine_specs = []
data_set = []
for spec in ("Name", "Speed in MHz", "Cores", "Cache in kB", "RAM in GB"):
data_val = input(f"{spec}: ")
if spec == "Speed in MHz":
data_val = float(data_val)
elif spec != "Name":
data_val = int(data_val)
data_set.append(data_val)
machine_specs.append(data_set)