编写子程序的不同方法

2024-04-19 19:18:58 发布

您现在位置:Python中文网/ 问答频道 /正文

是否有另一种方法来编写这个子例程并进行一些验证,或者有一种更无组织的方法来完成它?你知道吗

months=['January','February','March','April','May','June','July','August','September','October','November','December']
total=0
student=input('Enter new name: ')
for x in range (12):
    score=float(input('Enter score for ' + months [x] + ' out of 10: '))
    while score > 10 or score <1 or score %1 != 0 :
        float(score=input('Invalid','Enter score for' + months [x]+'out of 10: '))
        total=total+score
        print('Your total Score is', total)
        names.update[{name:totalscore}]

Tags: orof方法nameforinputfloatout