100% found this document useful (1 vote)
138 views2 pages

Python WS1 ANS

这是一个Python入门教程。它介绍了Python的基本概念,如变量、数据类型、运算符和注释。它包含了多个选择题来测试读者对这些基本概念的理解,以及两个编程练习来让读者实践这些知识。

Uploaded by

Chun Piu Wong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
138 views2 pages

Python WS1 ANS

这是一个Python入门教程。它介绍了Python的基本概念,如变量、数据类型、运算符和注释。它包含了多个选择题来测试读者对这些基本概念的理解,以及两个编程练习来让读者实践这些知识。

Uploaded by

Chun Piu Wong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python 1 Page 1 (2)

香海正覺蓮社佛教馬錦燦紀念英文中學
中二電腦科工作紙
Python 1: 簡介、 變量及運算符
日期: ___________
學生: ________________________ 班別: __________ ( )

A. 多項選擇題 (8 分, @1 分)
1. Python 中輸出“Hello World”的正確語法是什麼?
A. print("Hello World")
B. echo "Hello World" 改正:
C. WriteLine("Hello World")
A
D. echo("Hello World");

2. 以下哪些是 Python 程式中的註解?


(1) #This is a comment
(2) //This is a comment
(3) /*This is a comment*/
(4) """This is a comment"""
A. (1) 及 (2)
改正:
B. (2) 及 (3)
D
C. (3) 及 (4)
D. (1) 及 (4)

3. 在 Python 程式中,以下哪個不是有效的變量名稱?
A. Myvar B. _myvar 改正:
C. my var D. my_var
C

4. 在 Python 程式中,如何建立數值為唔的變量?
(1) x = 5
(2) x = int(5)
(3) x = "5"
A. (1) 及 (2)
B. (2) 及 (3) 改正:
C. (1) 及 (3)
A
D. (1), (2) 及 (3)
Python 1 Page 2 (2)

5. Python 程式的副檔名稱是? 改正:


A. .pt B. .py
B
C. .pyt D. .pyth

6. 在 Python 程式中,輸出變量屬那一個類型的語法是什麼?
A. print(typeof x)
B. print(typeof(x)) 改正:
C. print(typeOf(x))
D
D. print(type(x))

7. 下列哪個是 Python 程式中的乘號? 改正:


A. # B. %
C
C. * D. X

8. 下列哪個是 Python 程式中的比較運算符號? 改正:


A. >< B. ==
B
C. <> D. =

B. 編程 (7 分)
1. 編寫一個 Python 程式讀取 3 個整數值,然後計算該 3 個輸入數值之和,並把總和輸出。
(3 分)
a = int(input()) 輸入例子 輸出例子
2 Sum = 11
b = int(input()) (1) 3
c = int(input()) (1) 6

print("Sum= ",a+b+c) (1)

2. 編寫一個 Python 程式讀取 1 個整數值,然後把該輸入數值的前一個整數值和下一個整數


值輸出。 (3 分)
輸入例子 輸出例子
179 Next number for 179 is 180
Previous number for 179 is 178

N = int(input()) (1)

print("Next number for",N,"is",N+1) (1)

print("Previous number for",N,"is",N-1) (1)

You might also like