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

科目名稱:計算機概 論 開課系所:資訊工程 學系 考試日期 2013.11.26
系所別:
年級:
學號:
姓名:
考試時間 14:10-14:20
  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).
    # Pre-test (P.236)

    i = 1
    while i < 9:
        print(i)
        i = i + 2


  2. (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).
    # Loop and a Half (P.254)

    i = 1
    while True:
        i = i + 2
        if i == 9: break
        print(i)



  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).
    # Nested Loops (P.244)

    K = 5
    i = 1
    while i <= K:
        j = K - i
        while j > 0:
            print(end=' ')
            j = j - 1
        j = i
        while j > 0:
            print('*', end='')
            j = j - 1
        print()
        i = i + 1