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

科目名稱:計算機概 論 開課系所:資訊工程 學系 考試日期 2013.10.4
系所別:
年級:
學號:
姓名:
考試時間 08:10-08: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).
    # sep and end parameters of print()
    print('*', '*', '*', sep=':')
    for i in range(2):
        print('*', end=' ')
    for j in range(3):
        print('*')




  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).
    # Accumulating Results (P.62)
    sum = 0
    for i in range(5):
        sum = sum + i ** 2
    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).
    # int() vs. round()
    a=4.6
    print( int(a), round(a), int(-a), round(-a) )