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

科目名稱:計算機概 論 開課系所:資訊工程 學系 考試日期 2013.11.19
系所別:
年級:
學號:
姓名:
考試時間 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).
    # Pass by Value
    def append(s):
        for i in range( len(s) ):
            s[i] = s[i] * 2
        s = s + [4]
        print(s)

    def main():
        aList = [1, 2, 3]
        append(aList)
        print(aList)

    main()



  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).
    # Multi-Way Decision
    a = 5
    if a > 0 :
        print("a > 0")
    elif a < 10 :
        print("a < 10")



  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).
    # Simple Decision

    a = 5
    if a > 0 :
        print("a > 0")
    if a < 10 :
        print("a < 10")