Font size
WorksheetsÔN TẬP KIỂM TRA HỌC KỲ 2
Total questions: 113
Worksheet time: 1hrs 17mins
Chọn câu sai từ các câu sau:
Lệnh print() thực hiện nhiệm vụ in ra màn hình.
Lệnh input() yêu cầu nhập một biểu thức, số hoặc bất kỳ chuỗi nào.
Lệnh type() trả về kiểu dữ liệu của biểu thức trong dấu ngoặc.
Lệnh str() chuyển đổi đối tượng đã cho thành một chuỗi.
Số lượng câu đúng trong các câu sau:
Python cung cấp nhiều hàm tích hợp sẵn cho người dùng sử dụng theo ý muốn.
Lệnh float() chuyển đổi đối tượng đã cho thành số thực.
Lệnh int trả về một số nguyên từ một số hoặc biểu thức chuỗi.
Trong Python, người dùng chỉ có thể sử dụng các hàm tích hợp sẵn đã được định nghĩa trước.
Người dùng có thể tạo thêm các hàm mới.
Câu đúng từ các câu sau đây là:
Hàm float() trả về một số nguyên từ một biểu thức số hoặc chuỗi.
Có một số hàm tích hợp sẵn trong Python.
Hàm bool() chuyển đổi một giá trị thành Boolean.
Hàm input() có thể nhập một số nguyên mà không cần chuyển đổi kiểu.
Kết quả của chương trình sau đây là gì?
def chao(ten):
"""Hàm này dùng để
chào một người được truyền
vào như một tham số"""
print("Xin chào, " + ten + "!")
chao(‘Xuan’)
"Xin chào".
"Xin chào, Xuan!".
"Xin chào!".
Câu lệnh có lỗi.
Kết quả của chương trình sau là gì?
def PhepNhan(Number):
return Number * 10;
print(PhepNhan(5))
5.
10.
Chương trình có lỗi.
50.
Kết quả của chương trình sau đây là gì?
def Kieu(Number):
return type(Number);
print(Kieu (5.0))
5.
float.
Chương trình có lỗi.
int.
Chức năng của hàm sau đây là gì?
def sum(a, b):
print("sum = " + str(a + b))
Trả về tổng của hai số a và b được truyền vào.
Trả về hai giá trị a và b.
Tính tổng của hai số a và b.
Tính tổng của hai số a và b và hiển thị nó trên màn hình.
Điền vào chỗ trống (...) để tìm số lớn nhất trong 3 số đầu vào:
def find_max(a, b, c):
max = a
if (…): max = b
if (…): max = c
return max
max < b, max < c.
max <= b, max < c.
max < b, max <= c.
max <= b, max <= c.
Kết quả của chương trình sau là gì?
def get_sum(num):
tmp = 0
for i in num:
tmp += i
return tmp
result = get_sum(1, 2, 3, 4, 5)
print(result)
12.
13.
14.
15.
Tại dòng nào trong chương trình sau có lỗi?
a = "Hello Guy!"
def say(i):
return a + i
say(3)
print(a)
4.
2.
3.
Không có dòng nào có lỗi.
Tại dòng nào chương trình sau có lỗi?
Đoạn mã nào có lỗi?
4.
2.
3.
Không có đoạn nào có lỗi.
Đoạn mã nào có lỗi trong chương trình sau?
2.
3.
1.
Không có lỗi.
Kết quả của chương trình sau đây là gì?
3, 5, 9.
9, 15, 27.
9, 5, 27.
Chương trình có lỗi.
Khi khai báo một hàm, thành phần nào được định nghĩa và sử dụng như một biến trong hàm?
Tham số.
Đối số.
Dữ liệu.
Giá trị.
Chọn câu đúng từ các câu sau:
Gọi hàm không có lỗi nếu các tham số được truyền không có giá trị.
Số lượng giá trị được truyền cho hàm bằng số lượng tham số trong khai báo hàm.
Tham số là các giá trị được truyền khi gọi một hàm.
Tất cả ba câu trên đều đúng.
Which statement is incorrect?
A function can have one parameter when declared but can have two arguments when called.
Parameters are defined when declaring a function.
Parameters and arguments have some differences.
When calling a function, parameters are passed by value through the function's arguments.
Giả sử hàm f có hai tham số khi được khai báo. Hai giá trị đối số nào được truyền vào sẽ gây ra lỗi?
2, 3.
10, c.
"a", "b".
"a", "3".
Khi gọi hàm f(1, 2, 3), có bao nhiêu tham số được định nghĩa trong hàm f?
1.
2.
3.
4.
Kiểu dữ liệu của các tham số của f nếu hàm f được gọi như sau: f('5.0') là gì?
str
float.
int.
Không xác định.
Hoàn thành chương trình để kiểm tra xem một số có phải là số nguyên tố không:
Đúng, Sai.
Đúng, Đúng.
Sai, Sai.
Sai, Đúng.
Giá trị của m là bao nhiêu nếu kết quả là 5:
1.
4.
2.
3.
Giá trị của x là bao nhiêu nếu kết quả là 8:
3.
2.
1.
4.
Hoàn thành chương trình sau:
a.
b.
r.
Chương trình có lỗi.
Kết quả của chương trình này là gì?
384.
2.
4.
6.
Hoàn thành (...) trong câu sau: "Trong Python, tất cả các biến được khai báo bên trong một hàm là ... và không có tác động bên ngoài ... hàm."
cục bộ, bên trong.
cục bộ, bên ngoài.
cục bộ, bên ngoài.
toàn cục, bên ngoài.
Có bao nhiêu câu đúng trong các câu sau: 1) Tất cả các biến bên trong một hàm đều là biến cục bộ. 2) Tất cả các biến bên trong một hàm chỉ là biến cục bộ. 3) Các biến cục bộ trong một hàm sẽ gây ra lỗi nếu được gọi bên ngoài hàm.
1.
2.
3.
0.
Chọn câu sai từ các câu sau:
Chương trình chính có thể sử dụng các biến cục bộ bên trong một hàm.
Các biến bên trong một hàm có thể có cùng tên với các biến được khai báo bên ngoài hàm.
Tất cả các biến trong một hàm đều là cục bộ.
Các biến bên trong một hàm không có ảnh hưởng gì bên ngoài hàm.
Các giá trị của x, y khi thực hiện lệnh f(1, 3) là gì?
2, 3.
4, 5.
5, 4.
3, 4.
Các giá trị của a, b khi thực hiện lệnh f(2, 5) là gì?
10, 2.
10, 1.
2, 5.
0, 1.
Kết quả của chương trình này là gì?
"Tôi là: Long".
"Long".
"Tôi là: ".
Chương trình có lỗi.
Kết quả của chương trình sau đây là gì?
Kết quả của chương trình sau là gì? s = 'Hôm nay tôi đi học ' def kq(name): s = 'Hello World' s = s + '!!!' return s print(s)
'Hôm nay tôi đi học '
'Hello World'
'Hello World!!!'
Chương trình có lỗi.
Kết quả của chương trình sau là gì? def changeme(mylist): mylist.append([1,2,3,4]) mylist = [10,20,30] changeme(mylist) print(mylist)
[10, 20, 30]
[10, 20, 30, 1, 2, 3, 4]
[1, 2, 3, 4]
[10, 20, 30, [1, 2, 3, 4]]
Tại dòng nào chương trình sau có lỗi? def msg(): a=10 print('Giá trị của a là',a) return msg() print a
4
5
3
Không có lỗi.
Chọn câu sai từ các câu sau:
Các lỗi trong chương trình Python có thể được phân loại thành ba loại.
Khi có lỗi cú pháp, chương trình sẽ dừng ngay lập tức và báo lỗi.
Các lỗi thời gian chạy là những lỗi không thể thực thi một lệnh trong chương trình.
Cách xử lý các loại lỗi khác nhau là giống nhau.
Có bao nhiêu câu đúng trong các câu sau? 1) Chương trình chạy khi có lỗi logic xảy ra 2) Khi có lỗi ngữ pháp cấu trúc, chương trình vẫn chạy. 3) Khi có lỗi thời gian chạy, chương trình dừng lại và báo lỗi. 4) Mã lỗi trả về bởi lỗi thời gian chạy được gọi là mã lỗi thời gian chạy.
2
3
4
1
Điền vào chỗ trống để hoàn thành câu: 'Chương trình chạy mà không có lỗi thời gian chạy nhưng kết quả là .... Đây là một .... lỗi bên trong chương trình.'
sai, lỗi logic
đúng, Lỗi cú pháp
đúng, lỗi logic
sai, ngoại lệ
Câu chương trình sau báo lỗi gì? for i in range(10) print(i)
Lỗi kiểu
Lỗi tên
Lỗi cú pháp
Lỗi giá trị
Câu chương trình sau báo lỗi gì? n = 5 for i in range(n): prin(t)
Lỗi kiểu
Lỗi tên
Lỗi cú pháp
Lỗi giá trị
Câu lỗi nào mà chương trình sau đây báo cáo? lst = [1, 2, 3, 4, 5] for i in range(10): print(lst[i])
Lỗi IndexError
Lỗi NameError
Lỗi SyntaxError
Lỗi ValueError
Có lỗi gì trong chương trình sau? #Tính tích của 3 số nguyên dương đầu tiên. >>>s = 1 >>> for i in range(3) >>> s = s * i >>> print(s) 0
Lỗi logic
Lỗi cú pháp
Lỗi thời gian chạy
Không có lỗi
Mã lỗi nào được đưa ra khi lệnh cố gắng chia cho số không?
LỗiChiaChoKhong
LỗiKiểu
LỗiGiáTrị
LỗiCúPháp
Có mã lỗi runtime nào được đưa ra khi độ thụt lề của dòng không được căn chỉnh?
LỗiChiaChoKhông
LỗiKiểu
LỗiThụtLề
LỗiCúPháp
Có lỗi gì trong dòng sau? >>>A = [1, 2] >>>A[0.5]
Lỗi logic
Lỗi thời gian chạy
Lỗi cú pháp
Không có lỗi
Hoàn thành câu: 'Có nhiều công cụ và phương pháp khác nhau để kiểm tra chương trình. Các công cụ nhằm ... của chương trình và ..., ... các lỗi phát sinh trong tương lai.'
Tìm lỗi, ngăn chặn, dừng
Tìm lỗi, ngăn chặn, xử lý
Ngăn chặn, dừng, xử lý lỗi
Xử lý lỗi, ngăn chặn, dừng
Trong số các công cụ sau, công cụ nào không phải là công cụ để kiểm tra chương trình?
Công cụ in biến trung gian
Công cụ tạo tập dữ liệu kiểm tra
Công cụ thống kê dữ liệu
Công cụ điểm dừng trong phần mềm lập trình
Câu nào sau đây không chính xác về việc kiểm thử chương trình?
Hiện tại, có rất ít phương pháp và công cụ khác nhau cho việc kiểm thử chương trình.
Các chương trình cần được kiểm thử với một số tập dữ liệu kiểm thử bao gồm các đầu vào điển hình và đầu ra đã biết.
Các tập kiểm thử phụ thuộc vào các tiêu chí khác nhau.
Các tập dữ liệu kiểm thử nên có nhiều tập kiểm thử ngẫu nhiên,...
Nhận định nào là chính xác nhất khi nói về tập dữ liệu kiểm tra khi kiểm tra chương trình?
Tập dữ liệu kiểm tra nên đa dạng và bao phủ nhiều kịch bản khác nhau.
Tập dữ liệu kiểm tra nên giới hạn chỉ trong một vài trường hợp.
Tập dữ liệu kiểm tra nên được tạo ra ngẫu nhiên mà không có cấu trúc nào.
Tập dữ liệu kiểm tra chỉ nên bao gồm các trường hợp biên.
Nhận định nào chính xác nhất về tập dữ liệu kiểm tra khi kiểm tra một chương trình?
Tập kiểm tra có thể có đầu vào dựa trên các tiêu chí khác nhau.
Tập kiểm tra có đầu vào dựa trên một số tiêu chí nhất định.
Tập kiểm tra có thể có đầu vào dựa trên nhiều tiêu chí khác nhau như kích thước và sự đa dạng của dữ liệu.
Tập kiểm tra phải có đầu vào dựa trên các tiêu chí về kích thước và sự đa dạng của dữ liệu.
How many statements are correct in the following statements: 1) It is important to have multiple test sets when testing data sets. 2) Randomly generating input data within the defined domain of the program increases the likelihood of finding errors. 3) In reality, errors rarely occur at boundary areas or near boundaries. 4) It is not possible to use print() statements to output intermediate variables.
2.
3.
1.
4.
What error does the following program generate? >>> 1 / 0 0.5 >>> 2 ** 3 8
NameError.
TypeError.
ZeroDivisionError.
Syntax Error.
If the program generates an IndexError exception, how should it be handled?
Check the divisor value.
Check the index in the array.
Check the value of the number being divided.
Check the data type of the input.
Which line of code in the following program has an error? n = int(input("Enter a natural number n: ")) s = "" for i in range(10): s = s + i
1.
2.
3.
4.
To calculate the average value of a list of numbers A, the programmer used the command gttb = sum(A) / len(A). What exceptions might occur?
NameError.
ZeroDivisionError.
No errors can occur.
Both of the above errors may occur.
If the program generates a NameError exception, how should it be handled?
Check the index in the array.
Check the names of variables and functions.
Check the value of the number being divided.
Check the data type of the input.
Which job is directly related to graphic design?
Tailor.
Announcer.
Architect.
Secretary.
Which component is not included in graphic images?
Text.
Lines.
Basic shapes.
Graphic applications.
What are the benefits of graphic design?
Helps create a professional image.
Provides a special experience for readers.
Increases marketing effectiveness and revenue.
All of the above.
What skills are needed in graphic design?
Drawing, arranging graphic objects.
Computer skills.
Skills to work on graphic software.
All of the above.
Which factor is most essential for a graphic designer?
Ability to appreciate beauty and creativity.
Good calculation skills.
Proficiency in photo editing software.
Proficient in computer software.
What skills or qualities are most necessary for a graphic designer?
Deep understanding of mathematics.
Ability to proficiently use graphic design software and knowledge of technology.
Ability to play many musical instruments.
Ability to appreciate beauty.
Which software is not used by graphic designers to edit photos and create graphic designs?
Word.
Inkscape.
Adobe Photoshop.
Paint.
Which school offers training in graphic design?
University of Architecture.
University of Commerce.
Academy of Finance.
Academy of Agriculture.
What professions can one pursue after graduating in graphic design?
Design specialist.
Design consultant.
Establishing a consulting company or business.
All of the above.
Where can students pursue graphic design early?
Centers.
Vocational schools.
Colleges.
All of the above.
According to you, how many jobs will require graphic design knowledge?
Creating advertising posters for beverage products for the company.
Programming applications for graphic design.
Teaching cultural subjects.
Which of the following tasks will use graphic design knowledge?
Teaching graphic design at universities.
Consulting on product logo design.
Teaching cultural subjects at schools.
Consulting on studying abroad.
What is graphic design?
Arranging layout, editing images.
Choosing colors for images to create communication products.
Creating products that meet the requirements and objectives.
All of the above.
How many stages are needed to produce software?
5.
6.
7.
8.
Contacting customers, understanding business requirements, and building system requirements documentation is part of which stage in software production?
Programming.
Testing.
Delivery.
Survey.
Installation, initializing data, guiding usage, and delivery are part of which stage?
Programming.
Survey.
Testing.
Delivery.
What is the activity that encompasses all basic tasks of software production?
Software production.
Software project management.
Software management.
Software project.
Which statement is most accurate about software development?
Software development is programming.
Software development is a process that includes many tasks and activities.
Software development is a process that includes many tasks and activities, which can be repeated.
Software development is software project management.
What qualities are essential for a programmer?
Understanding algorithms, data structures.
Knowledge of computer science.
Careful and meticulous character.
All of the above.
Who is responsible for the most important tasks in software development?
Programmer.
Software engineer.
Project manager.
All of the above.
What does the work of a software engineer include?
Analysis, design, software development.
Testing and maintaining software.
Guiding software development.
All of the above.
After graduating from training courses, in which fields can I participate in software development jobs?
Application programming.
User interface development.
Web application development.
All of the above.
How do you evaluate job opportunities in the future for software development?
The demand for labor is constantly increasing.
Increasingly requires fewer workers.
Low-skilled labor.
All of the above.
Write a program to find the first n Fibonacci numbers.
Write a program to find the greatest common divisor (GCD) and least common multiple (LCM) of two positive integers a and b entered from the keyboard.
Write a program to list all prime numbers less than n. The positive integer n is entered from the keyboard.
Write a program to list the first n prime numbers in Python. The positive integer n is entered from the keyboard.
Write a program to list and count all prime numbers that have 5 digits.
Write a program to factor the integer n into its prime factors in Python.
What keyword is used to define a function in Python?
define
function
def
fun
What is the correct syntax to define a function without parameters in Python?
function myFunction():
def myFunction:
def myFunction():
define myFunction():
Given the code below: def chao(): print("Xin chào!") chao() What will be the output when the program runs?
Nothing happens
Prints 'chao'
Prints 'Xin chào!'
Error due to missing parameters
Given the code below: def tinh_tong(a, b): return a + b print(tinh_tong(3, 5)) What will the program output?
a + b
35
8
tinh_tong(3, 5)
Given the code below: def kiem_tra_so_chan(n): if n % 2 == 0: return True else: return False print(kiem_tra_so_chan(7)) What will the program output?
True
False
7
Nothing is printed
What is a parameter of a function?
The value returned by the function
The name of the function
A variable declared outside the function
A variable passed into the function when calling it
Where are parameters declared in Python?
In the body of the function
After the return keyword
In the parentheses after the function name
After the colon :
Given the code below: def tinh_hieu(a, b): return a - b kq = tinh_hieu(10, 3) print(kq) What will be the value of kq after running the program?
7
13
3
10
Given the code below: def tinh_trung_binh(a, b=5): return (a + b) / 2 print(tinh_trung_binh(3)) What will the program output?
4.0
3.0
8.0
Error due to missing parameters
What is the scope of a variable?
The value the variable receives after computation
The data type of the variable
The position in the program where the variable can be used
The name of the variable in the function
What do we call a variable declared inside a function?
Global variable
Internal variable
Local variable
Auxiliary variable
Given the code below: x = 10 def my_func(): x = 5 print(x) my_func() print(x) What will the program output?
5 and 5
5 and 10
10 and 5
10 and 10
Given the code below: def demo(): y = 7 print(y) demo() print(y) What will the program do?
Print 7 twice
Print 7 then report an error
Report an error immediately
Print nothing
Given the code below: a = 3 def test(): global a a = a + 2 test() print(a) What will be the output?
3
5
Error
2
What is the output of the following code: a = 3 def test(): global a a = a + 2 test() print(a)
3
5
Error
2
What is a syntax error in Python?
Error due to program logic
Error that occurs when the program runs
Error due to violation of coding rules
Error due to incorrect input data
Which of the following is a logic error?
Forgetting ':' after the if statement
Using an undeclared variable
Writing a program to calculate the average but using multiplication instead
Missing parentheses when calling a function
What error will the following code encounter: def add(a, b): return a + b print(add(5))
Syntax error
Logic error
Error due to missing parameters when calling the function
No error
What is the cause of the following error? NameError: name 'x' is not defined
Calling variable x when it has not been declared
Incorrect data type declaration
Missing parentheses
Error due to division by 0
What error will the following code encounter: a = 10 b = 0 print(a / b)
Syntax error
Logic error
Division by 0 (ZeroDivisionError)
No error
A program that runs but gives incorrect results is often due to:
Syntax error
Logic error
System error
Compilation error
What is program testing?
Adding more code to make the program longer
Automatically saving the program after writing
Running the program to detect errors
Changing variable names for better understanding
What is debugging a program?
Stopping the program when an error is detected
Deleting all source code and rewriting it
Identifying the cause and fixing errors in the program
Creating more errors for easier testing
Why is it necessary to test with multiple datasets?
To make the program run longer
To see if the computer is powerful
To ensure the program works correctly in all cases
To make the user not understand the program
What is the best way to test and avoid errors in the following code: def divide(a, b): return a / b print(divide(4, 0))
No need to do anything because the program is syntactically correct
Add print('Completed') after the function call
Add a check if b != 0: before dividing
Change division to addition
What is the first step when debugging a program that gives incorrect results?
Rewrite the program from scratch
Run the program with different input data
Read and check the logic of the source code
Delete the variable being used
What is the first step when writing a program?
Run the program
Debug the program
Identify the problem and requirements
Write commands based on inspiration
A simple program usually includes:
Hundreds of complex lines of code
Images and sounds
Input, processing, and output commands
Only the interface
