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")
for task in range(0,n_tasks):
print (f" {task + 1 } {priority[ task ]} {time[ task ]}")
test_list = [ 4, 5, 3, 7, 11, 2]
max_value = max(test_list) # use function max() to find maximum value in list
max_index = test_list.index(max_value) # use method list.index () to find the index where this max occurs
print (f" The max value is : {max_value} the index is : {max_index}") # print out results in formatted statement
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[max_index] # input the time it takes to complete this task
print (f"The max value is: {max_value} the index is: {max_index} and the max time it would take is {task_time}") # print out values as in Step #2 plus the time it takes to complete task
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[max_index]
print (f" the index of the max value in the list is: {max_index} and the max is: {test_list[max_index]} the max time it would take is: {task_time}")
if (task_time < (max_time - time_used) ) :
time_used = task_time + time_used
print (f" the {max_index + 1}th number in list was added and the time that is now used is {time_used}")
else:
print (f"item number {max_index + 1} is over the time limit")
# 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
total_time = 0
renT = 0
print ( f"TASK PRIORITY TIME TO COMPLETE")
for task in range(0, n_tasks) :
maxP = max(priority)
time_index = priority.index(maxP)
tim = time[time_index]
total_time = total_time + tim
print (f" {task + 1} {maxP} {tim}")
if (renT + tim <= max_time):
print(f"Do task {task + 1} with the time of: {tim}")
renT = renT + tim
print(f"The time used on this task was {tim} with the priority as {maxP} and the time remaning after this task is {max_time - renT}")
else:
print (f"Task {task + 1} not completed in the given time")
priority [time_index] = 0
print (f"The total time used for all tasks: {total_time}")
# 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
renT = 0
print ( f"TASK PRIORITY TIME TO COMPLETE")
#
for task in range(0, n_tasks) :
maxP = max(priority)
time_index = priority.index(maxP)
tim = time[time_index]
total_time = total_time + tim
print (f" {task + 1} {maxP} {tim}")
if (renT + tim <= max_time):
print(f"Do task {task + 1} with the time of: {tim}")
renT = renT + tim
print(f"The time that was used on this task is {tim} with the priority as {maxP} the time that is remaining after this task is {max_time - renT}")
if (renT ==max_time):
break
else:
print (f" task {task + 1} can not be finished in the given time")
priority [time_index]= 0
print (f" Total time for all of the tasks: {total_time}")
# Input problem specific data
old_priority = [ 2, 6, 1, 7, 10, 8, 5]
time = [30,200,20,70,120,60, 150]
# n_tasks = len(priority)
#
# Create new priority list containing ratios
#
priority = [time_index] # initialize the list which contains the new priorities which are original priority divided by
for i in range (n_tasks):
# add for loop to create this list
max_time:
# use method .append() to create elements of the new priority list
#
# Remainder of code should be the same; this is because we called the new list which contained the ratios the same as
# before.