priority = [2,6,1,7,10,8,5]
time = [30,200,20,70,120,60,150]
import numpy as np
#
# define number of tasks: don't hardwire this but rather use the len() command
n_tasks = len(priority)
max_time = 8*60
n = 0
n_list= np.array (np.linspace (1, n_tasks, n_tasks))
print ( f"TASK PRIORITY TIME TO COMPLETE")
for x in range (0, n_tasks):
print (f" {n_list [n]} {priority[n]} {time[n]}")
n = n +1
# you need to add an appropriate for loop here and modify the next print statement so that you can print out all tasks

```
TASK PRIORITY TIME TO COMPLETE
1.0 2 30
2.0 6 200
3.0 1 20
4.0 7 70
5.0 10 120
6.0 8 60
7.0 5 150
```

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"{max_index + 1}. {max_value}")
# print out results in formatted statement

```
5. 11
```

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"{max_index + 1}. {max_value}, time = {task_time}") # print out values as in Step #2 plus the time it takes to complete task

```
5. 11, time = 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 [max_index]
if (time_used <= max_time) :
time_used = time_used + task_time
print (f"Task number {max_index + 1} is complete, current time used = {time_used}")
else:
print ("There is not enough time to complete this task")

```
Task number 5 is complete, current time used = 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]
print ( f"TASK PRIORITY TIME TO COMPLETE")
#
# Initialize any variables before loop
n_tasks = len(priority)
max_time = 8*60
time_used = 0
#
# add for loop to go through all tasks
#
for x in range (0, n_tasks):
max_value = max(priority)
max_index = priority.index (max_value)
task_time = time [max_index]
priority[max_index] = 0
if (time_used + task_time <= max_time):
time_used = time_used + task_time
print (f" {max_index + 1} {max_value} {task_time}")
else:
print (f" Task {max_index +1} will not be completed in desired time")
print (f"*Total time of all tasks completed in day 1 = {time_used}*")
#
# find highest priority left and task number it corresponds to from Step 3/4
#
# zero out this entry in the priority list so you won't find it again
#
# 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

```
TASK PRIORITY TIME TO COMPLETE
5 10 120
6 8 60
4 7 70
2 6 200
Task 7 will not be completed in desired time
1 2 30
Task 3 will not be completed in desired time
*Total time of all tasks completed in day 1 = 480*
```

# 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)
time_used = 0
max_time = 8*60
print ( f"TASK PRIORITY TIME TO COMPLETE")
#
# Initialize any variables before loop
#
# add for loop to go through all tasks
#
for x in range (0, n_tasks):
max_value = max(priority)
max_index = priority.index (max_value)
task_time = time [max_index]
priority[max_index] = 0
if (time_used + task_time <= max_time):
time_used = time_used + task_time
print (f" {max_index + 1} {max_value} {task_time}")
if (time_used == max_time):
break
else:
print (f" Task {max_index +1} will not be completed in desired time")
print (f"*Total time of all tasks completed in day 1 = {time_used}*")
#
# find highest priority left and task number it corresponds to from Step 3/4
#
# zero out this entry in the priority list so you won't find it again
#
# add conditional to check to see if task can be completed as in Step 4
# if this conditional is satisfied then add another conditional to check if time_used = max_time; if so break out of loop
#
# Print out the total time used for all tasks in day 1

```
TASK PRIORITY TIME TO COMPLETE
5 10 120
6 8 60
4 7 70
2 6 200
Task 7 will not be completed in desired time
1 2 30
*Total time of all tasks completed in day 1 = 480*
```

# Input problem specific data
old_priority = [ 2, 6, 1, 7, 10, 8, 5]
time = [30,200,20,70,120,60, 150]
u_time = 0
# n_tasks =
n_tasks = len(priority)
# Create new priority list containing ratios
import numpy as np
ratio_priority = (np.array(old_priority)/ np.array(time))
n = 0
for x in range (0, n_tasks):
m_value = max(ratio_priority)
m_index = np.where(ratio_priority == n)
task_tim = np.where(ratio_priority == n)
ratio_priority[max] = 0
n = n + 1
if (u_time + task_tim <= m_time):
u_time = u_time + task_tim
print (f" {m_index + 1} {m_value} {task_tim}")
if (u_time == m_time):
break
else:
print (f" Task {m_index +1} will not be completed in desired time")
print (f"*Total time of all tasks completed in day 1 = {time_used}*")
# initialize the list which contains the new priorities which are original priority divided by
# time it takes to complete this task
# add for loop to create this list
# 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.

Execution error

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices