求助大佬,如何实现这个功能
本帖最后由 桐生战兔丶 于 2021-7-16 13:04 编辑想让这个程序能够反复使用而不是完成以后需要重新启动一次,所以我写了如图一的代码,但是我用的方法并不能实现如图二。求助大佬指点迷津
附上代码:
print('.....................................................')
h=input('enter your point >> ')
i=1
d=1
while d!=100:
while i!= 2:
if not h.isdigit():
print('your key words is not number')
h=input('enter your point >> ')
else :
i=i+1
y=int(h)
while i!= 3:
if y>100 or y<1:
print(' the number is entered by your entering must be between 1 and 100')
h=input('enter your point >> ')
else :
i=i+1
y=int(h)
if y > 60 and y < 80:
print (h+' got C')
d=d+1
elif y < 60:
print (h+' got D')
d=d+1
else :
print (h+' got A')
d=d+1 本帖最后由 青出于蓝 于 2021-7-16 13:20 编辑
while True:
print('.....................................................')
h=input('enter your point >> ')
i=1
d=1
while d!=2:
while i!= 2:
if not h.isdigit():
print('your key words is not number')
h=input('enter your point >> ')
else :
i=i+1
y=int(h)
while i!= 3:
if y>100 or y<1:
print(' the number is entered by your entering must be between 1 and 100')
h=input('enter your point >> ')
else :
i=i+1
y=int(h)
if y >= 60 and y < 80:
print (h+' got C')
d=d+1
elif y < 60:
print (h+' got D')
d=d+1
else :
print (h+' got A')
d=d+1
1,这个d!=100不需要,可以在外面套一个大循环实现
2,源代码有一点错误,判断时输入61为C,但输入60为A。判断代码写错了,已经改了
页:
[1]