现在,我已经尝试将主程序设为代码中的主要“功能”。但是当我运行它时,首先出现分析位,这不是我想要的。我想让我的代码执行以下操作:输出主程序,以便用户可以输入总分并输入测试中的得分。
“编写一个程序,该程序从键盘上输入一个项目部分的标记:“分析”,“设计”,“实施”和“评估”。程序应输出总分,等级和多少要进入下一个标记带,还需要更多标记。“
那是我的任务。
def analysis():
print("Welcome to the analysis section")
marktotal=int(input("Input mark total which is out of /100"))
marks=int(input("Input marks"))
totalanalysis=print("You got",marks,"/",marktotal)
if marks > 80 or marks == 80:
print("A*")
elif marks > 67 or marks == 67:
print("A")
elif marks > 54 or marks == 54:
print("B")
elif marks > 41 or marks == 41:
print("C")
elif marks > 31 or marks == 31:
print("D")
elif marks > 22 or marks == 22:
print("E")
elif marks > 13 or marks == 13:
print("F")
elif marks > 4 or marks == 4:
print("G")
elif marks ==0:
print("U")
return
analysis()
def design():
print("Welcome to the design section")
marktotal=int(input("Input mark total which is out of /100"))
marks=int(input("Input marks"))
totalanalysis=print("You got",marks,"/",marktotal)
return
design()
def main():
selectedsection=str(input("What section would you like to grade?"))#main program starts here
if selectedsection =="analysis":
analysis()
elif selectedsection =="design":
print("design")
elif selectedsection =="implementation":
print("implementation")
elif selectedsection =="evaluation":
print("evaluation")
if __name__ == "__main__":main()
```
不要调用函数,请从主函数外部的代码中删除analysis()
和design()
。