Home > Enterprise >  Can't figure out logic for this assignment
Can't figure out logic for this assignment

Time:02-12

school_days = 15
classes_per_day = 5
total_classes = 75
for counter in range(school_days):
    total_classes = total_classes   classes_per_day

print(total_classes)

Here are the instructions in the assignment:

Task - Change the values stored in the variables school_days, classes_per_day, and total_classes so that the loop calculates the classes for a student that has 15 school days left. The student has 5 classes per day. The final value of total classes should be 75.

Output: 75

I've been trying to figure this out for the last hour, and I don't know what I'm doing wrong.

CodePudding user response:

There is no syntax error (which is an error that forbids to run the code by the way) but nothing can happen with zeros

You may change the zeros by 15 and 5

school_days = 15
classes_per_day = 5

CodePudding user response:

I don't know exactly what you are trying to achieve but you could try this:

school_days = 1
classes_per_day = 0
total_classes = 0
total_classes = total_classes   classes_per_day
for counter in range(school_days):
    print(total_classes   1)

CodePudding user response:

There is no syntax error try changing the zeros to values like

school_days = 10
classes_per_day = 4
  • Related