ChatCrawlersearch across public Telegram Open the app
P

python خانه پایتون گروه آموزشی برنامه نویسی

сообщение · 2023-11-24 17:16 UTC
I
Replymessage unavailable
کد پایتون processes = [] n = int(input("Enter the number of processes: ")) for i in range(n): process = [] process.append(input("Enter process name: ")) process.append(int(input("Enter arrival time: "))) process.append(int(input("Enter burst time: "))) processes.append(process) # sort processes based on arrival time processes.sort(key=lambda x: x[1]) # calculate waiting time and turnaround time wt = [0] * n tat = [0] * n wt[0] = 0 tat[0] = processes[0][2] for i in range(1, n): wt[i] = wt[i-1] + processes[i-1][2] tat[i] = tat[i-1] + processes[i][2] - processes[i][1] # calculate average waiting time and turnaround time avg_wt = sum(wt) / n avg_tat = sum(tat) / n # print results print("Process\tArrival Time\tBurst Time\tWaiting Time\tTurnaround Time") for i in range(n): print(processes[i][0], "\t\t", processes[i][1], "\t\t", processes[i][2], "\t\t", wt[i], "\t\t", tat[i]) print("Average Waiting Time:", avg_wt) print("Average Turnaround Time:", avg_tat)

Вся лента · оригинал в Telegram

Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog