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

科目名稱:計算機概 論 開課系所:資訊工程 學系 考試日期 2014.9.30
系所別:
年級:
學號:
姓名:
考試時間 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).
    # Adding two variables
    a, b = "9", "30"
    c = a + b
    d = eval(a) + eval(b)

    print(c, d)


  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).
    # Definite Loop
    sum = 0
    for i in [1, 2, 3, 4, 5]:
        sum = sum + i
        print(sum)


  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).
    # Definite Loop
    sum = 0
    for i in range(5):
        sum = sum + i
    print(sum)


  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).
    # Stars
    for i in range(3):
        for j in range(i):
            print('*', end='')
    print()