bt.append(int(输入(f“输入进程{i}的突发时间 - >”)))当我运行代码时,我的代码的第11行显示无效语法

问题描述 投票:-2回答:1

当我运行FCFS调度程序时,它指出了一行错误

bt.append(int(input(f"Enter burst time for process: {i} ->")))

说语法错误

    #python code to implement FCFS CPU Scheduling

n = int(input("Enter number of processes:"))     
bt = []     # Burst Time 
wt = [0,0,0,0,0,0,0,0,0]     # Waiting Time
tat = [0,0,0,0,0,0,0,0,0,0]   # Turn around time

#Take input

for i in range (0,n):
    bt.append(int(input(f"Enter burst time for process: {i} ->")))
#Waitng time
for i in range(1,n):
    wt[i] = 0
    for j in range (0,i):
        wt[i] += bt[i]

# Turn around time

for i in range(0,n):
    tat[i] = wt[i] + bt[i]
print()
print("\t Process \t\t Burst Time \t\t Waitng Time \t\t Turn around time")    

for i in range(0,n):
    print(f"\t P[{i}] \t\t {bt[i]} \t\t  {tat[i]} ")
python syntax-error
1个回答
0
投票

您需要使用格式方法:

"Enter burst time for process: {i} ->".format(i=i)
© www.soinside.com 2019 - 2024. All rights reserved.