Question: Please don't copy from anywhere Can you edit (as much as you can) this Python code to be Round Robin scheduling algorithm, and add avg
Please don't copy from anywhere
Can you edit (as much as you can) this Python code to be Round Robin scheduling algorithm, and add avg turnaround time?
AND ATTACH THE RESULT and Check the solution please
print("FIRST COME FIRST SERVE SCHEDULLING")
n= int(input("Enter number of processes : "))
d = dict()
for i in range(n):
key = "P"+str(i+1)
a = int(input("Enter arrival time of process"+str(i+1)+": "))
b = int(input("Enter burst time of process"+str(i+1)+": "))
l = []
l.append(a)
l.append(b)
d[key] = l
d = sorted(d.items(), key=lambda item: item[1][0])
ET = []
for i in range(len(d)):
# first process
if(i==0):
ET.append(d[i][1][1])
# get prevET + newBT
else:
ET.append(ET[i-1] + d[i][1][1])
TAT = []
for i in range(len(d)):
TAT.append(ET[i] - d[i][1][0])
WT = []
for i in range(len(d)):
WT.append(TAT[i] - d[i][1][1])
avg_WT = 0
for i in WT:
avg_WT +=i
avg_WT = (avg_WT/n)
print("Process | Arrival | Burst | Exit | Turn Around | Wait |")
for i in range(n):
print(" ",d[i][0]," | ",d[i][1][0]," | ",d[i][1][1]," | ",ET[i]," | ",TAT[i]," | ",WT[i]," | ")
print("Average Waiting Time: ",avg_WT)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
