priority = [ 2, 6, 1, 7, 10, 8, 5]
time = [30,200,20,70,120,60, 150]
# define number of tasks: don't hardwire this but rather use the len() command
n_tasks = len(priority)
max_time =480
print ( f"TASK PRIORITY TIME TO COMPLETE ")
# you need to add an appropriate for loop here and modify the next print statement so that you can print out all tasks
for i in range(0,1):
print(f'{1} {priority[0]} {time[0]}')
print(f'{2} {priority[1]} {time[1]}')
print(f'{3} {priority[2]} {time[2]}')
print(f'{4} {priority[3]} {time[3]}')
print(f'{5} {priority[4]} {time[4]}')
print(f'{6} {priority[5]} {time[5]}')
print(f'{7} {priority[6]} {time[6]}')
TASK PRIORITY TIME TO COMPLETE
1 2 30
2 6 200
3 1 20
4 7 70
5 10 120
6 8 60
7 5 150
test_list = [ 4, 5, 3, 7, 11, 2]
max_value = max(test_list)
max_index = test_list.index(max_value)
print(f'The max value is {max_value}, The index of the max value is {max_index}')
The max value is 11, The index of the max value is 4
test_list = [ 4, 5, 3, 7, 11, 2]
time_list = [30, 45, 20, 120, 90, 70 ]
max_value = max(test_list)
max_index = test_list.index(max_value)
task_time = time_list[4]
print(f'The max value is {max_value}, The index of the max value is {max_index}, and the task time is {task_time}')
The max value is 11, The index of the max value is 4, and the task time is 90
max_time = 6 * 60 # this is not the maximum time available for your example but rather for testing
time_used = 3 * 60
#
# Following 6 statements are from Step 3
test_list = [ 4, 5, 3, 7, 11, 2]
time_list = [30, 45, 20, 120, 90, 70 ]
max_value = max(test_list)
max_index = test_list.index(max_value)
task_time = time_list[4]
print(f'The max value is {max_value}, The index of the max value is {max_index}, and the task time is {task_time}')
#
# Add conditional to see if this task can be completed in the allotted time
if task_time < max_time-time_used :
time_used = time_used - task_time
print(f'After the task {5} was completed the new current time is {max_time-time_used}')
The max value is 11, The index of the max value is 4, and the task time is 90
After the task 5 was completed the new current time is 270
# Input problem specific data and print it out from Step 1
priority = [ 2, 6, 1, 7, 10, 8, 5]
time = [30,200,20,70,120,60, 150]
n_tasks = len(priority)
max_time = 480
time_used=0
print ( f"TASK PRIORITY TIME TO COMPLETE")
for i in range(0,1):
print(f'{1} {priority[0]} {time[0]}')
print(f'{2} {priority[1]} {time[1]}')
print(f'{3} {priority[2]} {time[2]}')
print(f'{4} {priority[3]} {time[3]}')
print(f'{5} {priority[4]} {time[4]}')
print(f'{6} {priority[5]} {time[5]}')
print(f'{7} {priority[6]} {time[6]}')
# find highest priority left and task number it corresponds to from Step 3/4
max_value = max(priority)
max_index = priority.index(max_value)
task_time = time[4]
print(f'The max value is {max_value}, The index of the max value is {max_index}, and the task time is {task_time}')
# add conditional to check to see if task can be completed as in Step 4
# Print out the total time used for all tasks in day 1
if task_time < max_time :
time_used = max_time-task_time
print(f'After task {5} was completed the new current time is {max_time-task_time}')
TASK PRIORITY TIME TO COMPLETE
1 2 30
2 6 200
3 1 20
4 7 70
5 10 120
6 8 60
7 5 150
The max value is 10, The index of the max value is 4, and the task time is 120
After task 5 was completed the new current time is 360
# Input problem specific data and print it out from Step 1
priority = [ 2, 6, 1, 7, 10, 8, 5]
time = [30,200,20,70,120,60, 150]
n_tasks = len(priority)
max_time = 480
time_used=0
print ( f"TASK PRIORITY TIME TO COMPLETE")
for i in range(0,1):
print(f'{1} {priority[0]} {time[0]}')
print(f'{2} {priority[1]} {time[1]}')
print(f'{3} {priority[2]} {time[2]}')
print(f'{4} {priority[3]} {time[3]}')
print(f'{5} {priority[4]} {time[4]}')
print(f'{6} {priority[5]} {time[5]}')
print(f'{7} {priority[6]} {time[6]}')
# find highest priority left and task number it corresponds to from Step 3/4
max_value = max(priority)
max_index = priority.index(max_value)
task_time = time[4]
print(f'The max value is {max_value}, The index of the max value is {max_index}, and the task time is {task_time}')
# add conditional to check to see if task can be completed as in Step 4
# Print out the total time used for all tasks in day 1
if task_time < max_time :
time_used = max_time-task_time
print(f'After task {5} was completed the new current time is {max_time-task_time}')
if task_time > max_time:
break