NEW
Font size
WorksheetsQuizz Python Revision
Total questions: 21
Worksheet time: 11mins
In programming, what is iteration?
The repetition of steps within a program
program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
Which two statements are used to implement iteration/Repetition)?
IF and WHILE
ELSE and WHILE
FOR and WHILE
IF and ELS
Which type of loop iterates until instructed otherwise?
FOR loop
A count-controlled loop
Repeat-once loop
WHILE loop
The condition for a while loop to continue could include which of the following?
While something equals something
While something is True
While something is greater than something
All of these
Which of the following symbols is used in Python to mean "Not equal to"?
==
!=
<>
><
5
4
3
2
1
4
3
2
1
0
5 4 3 2 1
4 3 2 1 0
Hello world!
Hello world
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
Error
Which of these codes is correct for creating a list of numbers?
num = ('10','29','37','109')
num = ['10','29','37','109']
num == ('10','29','37','109')
num = ['10 29 37 109']
What is the index number for 'Spain'?
['England','Brazil','Spain','France']
0
1
2
3
What does the '#' allow you to do?
Repeat code
Print code
Comment on code
End code
Trong Python, khi muốn thay thế một từ hoặc cụm từ bằng từ hoặc cụm từ khác thì ta sử dụng hàm nào sau đây?
upper()
find()
len()
replace()
Trong Python, cho xâu a=”Trường PT Hermann Gmeiner Đà Nẵng” và xâu b=’Hermann’ để tìm ra vị trí xuất hiện của xâu b có trong xâu a ta sử dụng câu lệnh nào sau đây?
print(a)
k=len(a)
k=len(b)
k=a.find(b)
Cách nào sau đây là cách hợp lệ để bắt đầu định nghĩa hàm trong Python?
def some_function()
function some_function()
function some_function():
def some_function():
Chương trình sau in ra kết quả gì?
8
5
21
18
Chương trình sau in ra kết quả gì?
13
21
5
Không in gì
Lệnh gọi hàm nào sau đây là đúng?
x=square( )
x=Square(4):
x=square(5)
print(square())
Câu lệnh return dùng để?
Kết thúc vòng lặp
Trả lại giá trị
Kết thúc hàm và trả lại giá trị
Kết thúc vòng lặp và trả lại giá trị
Chọn những phát biểu sai về chương trình con trong các phát biểu dưới đây
Chương trình được tạo thành từ các chương trình con dễ đọc, dễ hiểu, dễ hiệu chỉnh và phát triển.
Tham số của chương trình con bắt buộc phải có
Các lệnh của chương trình con có lệnh thụt vào so với từ khóa def
Chương trình con cần được xây dựng trước khi sử dụng
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
nameList["4"]
What output will this code produce?
blue
green
red
error
What is the result
You can buy some chocolate
You are rich!
Get a job!
You almost have enough
Get a job!
