正确示范1
score = int(raw_input('input score:\n'))
if score >= 90:
    grade = 'A'
if score <90 and score >= 60:
    grade = 'B'
if score < 60:
    grade = 'C'
print '%d belongs to %s' % (score,grade)
 
正确示范2
score = int(raw_input('input score:\n'))
if score >= 90:
    grade = 'A'
elif score >= 60:
    grade = 'B'
else:
    grade = 'C'
print '%d belongs to %s' % (score,grade)
 
 
 
错误示范1
score = int(raw_input('input score:\n'))
if score >= 90:
    grade = 'A'
#下面的if和else作为一个组合了,会导致99 belongs to C。
if score <90 and score >= 60:
    grade = 'B'
else:
    grade = 'C'
print '%d belongs to %s' % (score,grade)
 
错误示范2
score = int(raw_input('input score:\n'))
if score >= 90:
    grade = 'A'
#下面的if和else作为一个组合了,会导致99 belongs to B。
if score >= 60:
    grade = 'B'
else:
    grade = 'C'
print '%d belongs to %s' % (score,grade)
 
 
 

相关文章:

  • 2022-02-07
  • 2021-08-14
  • 2021-11-08
  • 2021-09-16
  • 2021-07-02
  • 2021-10-02
  • 2021-07-09
  • 2021-07-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
相关资源
相似解决方案