國立暨南國際大學 103 學年度第一學期小考試卷

科目名稱:計算機概 論 開課系所:資訊工程 學系 考試日期 2014.11.18
系所別:
年級:
學號:
姓名:
考試時間 14:20-14:35
  1. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    # Simple Decision
    a = 11
    b = 18
    n = 0
    if a > 11 :
        n = n + 1
    if b < 20 :
        n = n + 1
    print(n)



  2. (10%) Consider the following decision strucutre:
    a, b, c, = eval(input('Enter three numbers: '))
    if a > b:
        if b > c:
            print("Spam Please!")
        else:
            print("It's a late parrot!")
    elif b > c:
        print("Cheese Shoppe")
        if a >= c:
            print("Cheddar")
        elif a < b:
            print("Gouda")
        elif c == b:
            print("Swiss")
    else:
        print("Trees")
        if a == b:
            print("Chestnut")
        else:
            print("Larch")
    print("Done")
    What will be the output that would result from each of the following possible inputs:
    (a) 3, 4, 5
    (b) 3, 3, 3

  3. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    # Multi-Way Decision
    a = 11
    b = 18
    n = 0
    if a > 11 :
        n = n + 1
    elif b < 20 :
        n = n + 1
    else:
        n = n + 10
    print(n)



  4. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    # Two-Way Decision
    a = 11
    b = 18
    n = 0
    if a > 11 :
        n = n + 1
    else
        n = n + 10
    if b < 20 :
        n = n + 1
    else:
        n = n + 10
    print(n)