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

科目名稱:計算機概 論 開課系所:資訊工程 學系 考試日期 2013.10.8
系所別:
年級:
學號:
姓名:
考試時間 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).
    # print(objects, sep='', end='\n')
    for i in range(1, 6, 2):
        print(i, i+1, sep=',')



  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).
    # Type Conversion
    # int() will truncate the fractional part

    a = 4.8
    b = a + 0.5
    print(a, int(a))
    print(-a, int(-a))
    print(b, int(b))
    print(-b, int(-b))



  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).
    # Accumulator
    sum = 0
    for i in range(1, 6):
        sum = sum + i
        print(i, sum)