zoukankan      html  css  js  c++  java
  • if条件判断

    正确示范1
    score = int(raw_input('input score: '))
    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: '))
    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: '))
    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: '))
    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)
     
     
     
  • 相关阅读:
    HTML入门之003
    html入门之002
    HTML入门之001
    端口
    计算机基础
    二进制的学习
    markdown基础
    css基础
    html基础之三
    html基础之二
  • 原文地址:https://www.cnblogs.com/myshuzhimei/p/11753863.html
Copyright © 2011-2022 走看看