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)
     
     
     
  • 相关阅读:
    Path Sum 解答
    Binary Tree Paths 解答
    Populating Next Right Pointers in Each Node 解答
    Validate Binary Search Tree 解答
    First Missing Positive
    78 Subsets
    47.Permutations 1&2
    N-Queens 1&2
    Combination Sum_DFS
    38.Count and Say
  • 原文地址:https://www.cnblogs.com/myshuzhimei/p/11753863.html
Copyright © 2011-2022 走看看