WorksheetsĐề Cương Học Kì 2 - Khối 10
Total questions: 91
Worksheet time: 1hrs 16mins
Trong Python, có bao nhiêu loại cấu trúc vòng lặp?
1.
2.
3.
4.
Đâu là câu trả lời đúng trong chương trình sau? x=0 for i in range(10): x=x+1 print(x)
Chương trình in các số nguyên từ: 0 đến 10.
Chương trình in các số nguyên từ: 0 đến 9.
Chương trình in các số nguyên từ: 1 đến 10.
Chương trình in các số nguyên từ: 1 đến 9.
Cú pháp của vòng lặp for được cấu trúc như sau: for i in range(n) trong đó n là một số nguyên dương, vòng lặp này được thực hiện bao nhiêu lần?
n+1 lần.
n-1 lần.
không thể xác định.
n lần.
Xem xét chương trình sau: sodem=1 while sodem<5: print(sodem,end="") sodem=sodem+1 Sau khi thực thi chương trình trên, giá trị của 'sodem' là?
1234.
12345.
4321.
1.
Điền vào (...) để 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.
Xem xét hai chương trình dưới đây, câu nào sau đây là đúng?
(a,b,c) là tham số, (x,y) là đối số.
(a,b,c) là đối số, (x,y) là tham số.
(a,b,c) và (x,y) đều là đối số.
(a,b,c) và (x,y) đều là tham số.
Trong số các phát biểu sau, phát biểu nào là sai?
Các biến được khai báo bên trong một hàm có thể được sử dụng bởi chương trình chính.
Các biến được khai báo bên ngoài một hàm chỉ có thể truy cập giá trị của chúng bên trong hàm mà không thay đổi (trừ trường hợp sử dụng từ khóa global).
Trong Python, tất cả các biến được khai báo bên trong một hàm đều là biến cục bộ (scope), và không có tác động bên ngoài hàm.
Các biến được khai báo bên trong một hàm chỉ có thể được sử dụng trong hàm đó. Chương trình chính không thể sử dụng chúng.
Kết quả của chương trình sau: def my_function(x): return 3 * x print(my_function(3)) print(my_function(5)) print(my_function(9))
3, 5, 9.
9, 15,
Kết quả của chương trình sau là gì: def my_function(x): return 3 * x print(my_function(3)) print(my_function(5)) print(my_function(9))
3, 5, 9.
9, 15, 27.
9, 5, 27.
Chương trình có lỗi.
Chức năng của hàm sau là gì? def sum(a, b): print("tổng = " + 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ó.
Để biết độ dài của chuỗi s, hàm nào nên được sử dụng?
str(s)
len(s)
length(s)
s.len()
Cho chuỗi s1='ab', chuỗi s2='a' với cú pháp: s2 in s1 sẽ cho kết quả là:
đúng
Đúng
sai
False
Đối với chuỗi s = "Python"; giá trị của len(s) và s[1] là gì?
6 và 'P'
6 và 'y'
5 và 'y'
5 và 'P'
Để truy cập phần tử đầu tiên của một danh sách trong Python, chỉ số nào nên được sử dụng?
0
1
2
-1
Trong Python, lệnh nào được sử dụng để thêm một phần tử vào cuối danh sách?
add()
insert()
append()
extend()
Trong Python, lệnh nào được sử dụng để chèn một phần tử vào một vị trí cụ thể trong danh sách?
add()
insert()
append()
extend()
Để khai báo một danh sách rỗng Z, đâu là khai báo đúng?
Z=[ ]
Z=""
Z=( ).
Z=0
Chọn tùy chọn đúng cho kết quả của chương trình sau:
0 1 2
traicay
1 2 3.
xoài cốc ổi.
Giả sử A = [5, 6, 7, 8, 9, 10, 11, 12]. Biểu thức sau có trả về true hay false không? (3 + 4 - 5 + 18 // 4) trong A
Đúng.
Sai.
Không xác định.
Câu lệnh có lỗi.
Trong số các phát biểu sau, phát biểu nào là đúng?
Sau khi thực hiện lệnh clear(), các phần tử trả về giá trị 0.
Lệnh remove trả về False nếu không có trong danh sách.
remove() được sử dụng để xóa một phần tử có giá trị nhất định trong danh sách.
Lệnh remove() xóa một phần tử tại vị trí nhất định.
Chọn tùy chọn đúng cho chương trình sau:
[1, 2, 3, 4, 5, 6, 6, 5]
[1, 2, 3, 4]
[6, 5]
[1, 2, 3, 4, 5, 6].
What is the effect of () in Python?
Chọn tùy chọn đúng cho chương trình sau:
[1, 2, 3, 4, 5, 6, 6, 5]
[1, 2, 3, 4]
[6, 5]
[1, 2, 3, 4, 5, 6]
Chọn câu sai từ các câu sau:
Các lỗi trong 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à như nhau.
Which of the following statements is correct?
The float() function returns an integer from a number or string expression.
There are few built-in functions available in Python.
The bool() function converts a value to Boolean.
The input() function can input an integer without type conversion.
Câu nào sau đây là sai?
Bạn có thể truy cập từng ký tự của một chuỗi thông qua chỉ số.
Chỉ số bắt đầu từ 0.
Bạn có thể thay đổi từng ký tự của một chuỗi.
Python không có kiểu dữ liệu ký tự.
Kết quả của chương trình sau là gì?
5.
10.
Chương trình có lỗi.
50.
Giả sử A = [5, 6, 7, 8, 9, 10, 11, 12]. Biểu thức sau có trả về true hay false không? (3 + 4 - 5 + 18 // 4) trong A
Đúng.
Sai.
Không xác định.
Câu lệnh có lỗi.
Kết quả của chương trình sau đây là gì?
1 2 3 4 5 6
1 2 3 4 5 6 5
1 2 3 4 5
2 3 4 5 6 5.
Giả sử A = ['a', 'b', 'c', 'd', 2, 3, 4]. Các biểu thức sau có trả về true hay false không? 6 in A, 'a' in A
Đúng, Sai.
Đúng, Sai.
Sai, Đúng.
Sai, Sai.
Trong Python, lệnh nào truy cập phần tử 'a' trong danh sách X=[1, 5, -12, 'a', 'kf']?
X[3]
X=[5]
X[4]
X=[6]
Giả sử A=[1,2,3,4]. Kết quả của câu lệnh 4 có trong A là gì?
Đúng
Sai
đúng
Sai
Chuỗi trong Python là gì?
Chuỗi là một dãy các ký tự Unicode.
Một dãy các số.
Bất kỳ số nào tùy ý.
Bất kỳ giá trị nào tùy ý.
Ý nghĩa của hàm len là gì?
Trong Python, chuỗi là gì?
Một chuỗi là một dãy các ký tự Unicode
Một dãy các số
Bất kỳ số nào
Bất kỳ giá trị nào
Có nghĩa của hàm len là gì?
Viết hoa một chuỗi
Trả về độ dài của một chuỗi
Sao chép một chuỗi
Xóa một ký tự trong chuỗi
Từ khóa nào được sử dụng để định nghĩa một hàm trong Python?
func
def
abs
len
Khi gọi một hàm, dữ liệu được truyền vào hàm được gọi là gì?
Đối số
Tham số
Hệ số
Số hàm
Để tái sử dụng một biến toàn cục như một biến cục bộ, từ khóa nào được sử dụng để khai báo nó?
def
int
global
local
Câu nào sau đây là sai về phạm vi của biến trong Python?
Một biến được khai báo bên trong một hàm chỉ có hiệu lực trong hàm đó và không có hiệu lực bên ngoài.
Một biến được khai báo bên ngoài một hàm sẽ không có hiệu lực bên trong hàm như một biến.
Một biến được khai báo bên ngoài sẽ cần được khai báo lại bên trong hàm với từ khóa global để có hiệu lực bên trong.
Một biến trong Python, một khi đã được khai báo, sẽ có hiệu lực trong tất cả các hàm và bên ngoài.
Có bao nhiêu loại lỗi chương trình Python?
2
3
4
5
Giả sử chương trình có lệnh nhập sau: n = int(input("Nhập một số nguyên n: ")) Khi nhập 1.5, lỗi ngoại lệ nào xảy ra?
Cú pháp lỗi
Lỗi kiểu
Lỗi giá trị
Lỗi chỉ số
Mục đích của việc kiểm tra chương trình là gì?
Tự động sửa lỗi chương trình
Tìm lỗi trong chương trình
Tìm lỗi và tự động sửa lỗi chương trình
Tìm lỗi và ngăn chặn các lỗi trong tương lai xảy ra
Dựa trên kiến thức về hàm trong Python, xác định xem các câu sau đây là đúng hay sai: Ý nghĩa tham số hàm float(x) x có thể là một số hoặc một chuỗi Chuyển đổi x thành một số thập phân str(x) x có thể là một số hoặc một chuỗi Chuyển đổi x thành một chuỗi len(x) x là một danh sách hoặc một chuỗi Độ dài của đối tượng x list(x) x là một chuỗi hoặc hàm ngang () Chuyển đổi x thành một danh sách
Đúng
Sai
Xác định xem các phát biểu sau có đúng hay sai dựa trên kiến thức của bạn về một số hàm trong Python: a) Biểu thức abs(-5) sẽ trả về giá trị 5. b) Biểu thức bool(0) sẽ trả về giá trị True. c) Biểu thức ord('A') sẽ trả về giá trị 65. d) Biểu thức chr(97) sẽ trả về ký tự 'B'.
Đúng
Sai
Đối với ví dụ sau: >>>def func_tong(a,b,c): return a+b+c >>>m,n=12,9 >>>func_tong(15,m,n) a) Tên hàm là func_tong b) a, b, c là tham số c) Lời gọi hàm là func_tong(a,b,c): d) Các đối số của chương trình là 15, m, n.
Đúng
Sai
Đối với chương trình sau: #exponent def luythua(a,n): return a**n a = int(input('Nhập cơ sở:')) n = int(input('Nhập số mũ:')) print(a, 'lên lũy thừa', n, '=', luythua(a,n)) a) Tên hàm là luythua b) Trong câu lệnh def luythua(a,n): a, n là tham số c) Trong câu lệnh print(a, 'lên lũy thừa', n, '=', luythua(a,n)) a, n là đối số d) Lời gọi hàm là def luythua(a,n):
Đúng
Sai
Đối với chương trình sau: # Tính giai thừa; def giaithua(n): gt=1; for i in range(1, n+1): gt *= i; return gt; n = int(input('Nhập số để tính giai thừa:')); print(n, 'giai thừa =', giaithua(n)); a) Trong câu lệnh def giaithua(n): n là một tham số b) Chương trình khai báo 2 tham số c) Trong câu lệnh print(n, 'giai thừa =', giaithua(n)); n là một đối số d) Các tham số được viết trong dấu ngoặc đơn ngay sau tên hàm.
Đúng
Sai
Đối với chương trình sau: #COMBINATION; def gt(n): kq=1; for i in range(1,n+1): kq=kq*i; return kq; def c(n,k): return gt(n)/(gt(k)*gt(n-k)); print('CHƯƠNG TRÌNH TÍNH TOÁN N KẾT HỢP K:'); n=int(input('Nhập n = ')); k=int(input('Nhập k = ')); print('C(',n,',',k,') = ' , c(n,k)); a) Trong câu lệnh def gt(n): n là một tham số b) Chương trình khai báo các tham số n, k.
Đúng
Sai
Trong câu lệnh def gt(n):, n là một tham số.
[True] Trong câu lệnh def gt(n):, n là một tham số
[True] Chương trình khai báo các tham số n, k
[True] Trong câu lệnh print(…, c(n,k));, n, k là các tham số
[True] Trong câu lệnh return gt(n)/…;, n là một tham số
For the following program: # First 10 Fibonacci numbers of the sequence def fibonacci(n): if (n < 0): return -1; elif (n == 0 or n == 1): return n; else: return fibonacci(n - 1) + fibonacci(n - 2); print('First 10 Fibonacci numbers: '); sb = ''; for i in range(0, 10): sb = sb + str(fibonacci(i)) + ' '; print(sb)
[True] The function name is fibonacci(n) with parameter n
[True] In the statement sb = sb + str(fibonacci(i)) + ' '; i is an argument
[True] fibonacci(n - 1), fibonacci(n - 2) are parameters of the program
[True] In the statement return n; n is an argument
For the following program: # Finding the greatest common divisor (GCD) def uscln(a, b): if (b == 0): return a; return uscln(b, a % b);
[True] In the statement def uscln(a, b):, the function uscln(a, b) has arguments a, b
[True] If we call uscln(m, n): the program will report an error
[True] The function uscln(a, b) finds the greatest common divisor of a and b
[True] If we call uscln(9, 12): the program will yield the result 9
For the following program: # Finding the greatest common divisor (GCD) def uscln(a, b): if (b == 0): return a; return uscln(b, a % b); # Finding the least common multiple (LCM) def bscnn(a, b): return int((a * b) / uscln(a, b));
[True] The parameters of the program are a, b
[True] If we call bscnn(x, y) the program will return the result x
[True] If we call bscnn(9, 6, 3) the program will return the result 9
[True] In the statement return int(…/ uscln(a, b)); a, b are arguments
For the following program: # Exponentiation def luythua(a,n): return a**n a = int(input('Enter base:')) n = int(input('Enter exponent:')) print(a, 'to the power of', n, '=', luythua(a,n))
[True] The variables a, n are local variables
[True] When entering a=2, b=3 the program will output 6
[True] The variables a, n are effective in the function def luythua(a,n) and are effective throughout the entire program
When entering a=2, b=3, the program outputs 6.
True
False
In the program, the variables x, y, z are local variables.
True
False
The result 51 is not the result of the command return x+y+z.
True
False
After executing the command a(7,10), the values of m=3 and n=5.
True
False
The variables m, n are local variables of the program.
True
False
The result of the program is 35.
True
False
The variables gt, n, i are local variables.
True
False
If n=5 is entered, the result of the program is 25.
True
False
In the program, the variable gt is initially assigned 1.
True
False
Given the program below: #COMBINATION; def gt(n): kq=1; for i in range(1,n+1): kq=kq*i; return kq; def c(n,k): return gt(n)/(gt(k)*gt(n-k)); print('PROGRAM TO CALCULATE N COMBINATION K:'); n=int(input('Enter n = ')); k=int(input('Enter k = ')); print('C(',n,',',k,') = ' , c(n,k));
[TH] The variables kq, i, n, k are local variables
[TH] The variables kq, i, n, k are global variables
[TH] If we enter n=10, k=2 then the result of the program is 10
[TH] In the above program, it is not allowed to enter data for the variables n=k
Given the program below: # The first 10 Fibonacci numbers of the sequence def fibonacci(n): if (n < 0): return -1; elif (n == 0 or n == 1): return n; else: return fibonacci(n - 1) + fibonacci(n - 2); print("The first 10 numbers of the Fibonacci sequence: "); sb = ""; for i in range(0, 10): sb = sb + str(fibonacci(i)) + " "; print(sb)
[TH] The variable n is a local variable
[TH] The variables n, i, sb are local variables
[TH] If we enter n=50 then the result of the program is 100
[TH] The variable n is a global variable
Given the program below: # Find the greatest common divisor (GCD) def uscln(a, b): if (b == 0): return a; return uscln(b, a % b);
[TH] The variables a, b are local variables
[TH] The variables a, b cannot be assigned the same value a=b
[TH] If we enter a=50 and b=30 then the result of the program is 50
[TH] The variables a, b are global variables
Given the program below: # Find the greatest common divisor (GCD) def uscln(a, b): if (b == 0): return a; return uscln(b, a % b); # Find the least common multiple (LCM) def bscnn(a, b): return int((a * b) / uscln(a, b));
[TH] The variables a, b are local variables
[TH] The variables a, b cannot be assigned the same value a=b
[TH] If we enter a=50 and b=30 then the result of the program bscnn(a, b) is 30
[TH] The variables a, b are global variables
Given the command below: >>>n=int(input(" Enter number n=")) n=25,8
[TH] The program reports a SyntaxError: invalid syntax
[TH] The program reports an error Traceback (most recent call last):
File "pyshell#0, line 1, in
What is the error when trying to convert '25,8' to an integer?
SyntaxError: invalid syntax
ValueError: invalid literal for int() with base 10: '25,8'
Change n=int(input(" Nhập số n=")) to n=float(input(" Nhập số n="))
Change the input n to any integer value
The program sorts the array [6, 9, 1, 4, 7, 0, 5] in descending order. What is the result?
The program may have a semantic error because it gives the wrong result
The program may have a logic error because it gives the wrong result
SyntaxError: invalid syntax
To get the correct result, the initial array [6, 9, 1, 4, 7, 0, 5] must be rewritten as ["6, 9, 1, 4, 7, 0, 5"]
The program sorts the array [8, 3, 0, 9, 12, 1, 15] in ascending order. What is the result?
The program may have a semantic error because it gives the wrong result
The program may have a logic error because it gives the wrong result
SyntaxError: invalid syntax
To get the correct result, the initial array [8, 3, 0, 9, 12, 1, 15] must be rewritten as ["8, 3, 0, 9, 12, 1, 15"]
The program needs to be tested with a set of data that includes typical inputs depending on the specific characteristics of the problem and known outputs.
The program only needs 1 test case, no need for multiple test cases based on different criteria.
The program needs random test cases
The program needs test cases with boundary data
Simple programs do not need any test cases
Given the program: a = input("Enter number a: ") b = input("Enter number b: ") print("The sum of the two entered numbers is: ", a+b)
Given the program: a = input("Enter number a: ") b = input("Enter number b: ") print("The sum of the two entered numbers is: ", a+b) What can be said about this program?
[TH] The program does not generate any errors
[TH] If a=50 and b=5 are entered, the result of the program is 55
[TH] The first two lines can be modified as follows: a=int(input("Enter number a: ")) b=int(input("Enter number b: "))
[TH] The first two lines can be modified as follows: a=float(input("Enter number a: ")) b=float(input("Enter number b: "))
Given the program that sorts an array of numbers as follows: M=[7, 21, 0, 6, 9, 23, 18] for i in range(len(M)-1): j=i while j>1 and M[j] < M[j-1]: M[j],M[j-1]= M[j-1], M[j] J=j-1 print(M) What can be said about this program?
[TH] Line 1 has an error
[TH] Line 2 has an error
[TH] Line 4 has an error
[TH] Line 7 has an error
Let UCLN(a, b) be the GCD function of two natural numbers a, b. It can be seen that UCLN(a,b)=UCLN(b, a%b) if b>0 and UCLN(a,0)=a. Write a program to input two numbers a, b and calculate the GCD of a, b.
[TH] The program is written as follows: def uscln(a, b): if (b == 0): return a; return uscln(b, a % b); a = int(input("Enter positive integer a: ")); b = int(input("Enter positive integer b: ")); print("The greatest common divisor of", a, "and", b, "is:", uscln(a, b));
[TH] The program is written as follows: def UCLN(a,b): r = a % b while r != 0: a = b b = r r = a % b return b
[TH] The program is written as follows: def luythua(a,n): return a**n a = int(input('Enter base:')) n = int(input('Enter exponent:')) print(a, 'to the power of', n, '=', luythua(a,n))
[TH] The program is written as follows: def UCLN(a,b): r = a % b while r != 0: a = b b = r r = a % b return b a=int(input("Enter the first natural number")) b=int(input("Enter the second natural number")) print("The GCD of a and b is: ",UCLN(a,b))
The program inputs a positive odd real number a from the keyboard. The program needs to check the input data as follows: If the entered number is negative, or equal to 0, or even, then notify: "The entered number is incorrect, a must be greater than 0 and be odd. Please re-enter!" The program only stops when the user enters correctly.
The number entered is incorrect, number a must be greater than 0 and odd. Please enter again!
a=int(input("Enter a positive real number: ")) while a<=0: print("The number entered is incorrect, number a must be greater than 0 and odd. Please enter again!") a=int(input("Enter a positive real number: "))
a=float(input("Enter a positive real number: ")) while a>=0: print("The number entered is incorrect, number a must be greater than 0 and odd. Please enter again!") a=float(input("Enter a positive real number: "))
a=float(input("Enter a positive real number: ")) while a<=0: print("The number entered is incorrect, number a must be greater than 0 and odd. Please enter again!") a=float(input("Enter a positive real number: "))
a=float(input("Enter a: ")) while a<=0: print("The number entered is incorrect, number a must be greater than 0 and odd. Please enter again!") a=float(input("Enter a: "))
Enter a positive integer a which is one side of a square. Print the area and perimeter of it.
a=int(input('Enter one side of the square:')) dt=a*a cv=a*4 print('Area of the square:', dt) print('Perimeter of the square:', cv)
a=float(input('Enter one side of the square:')) dt=a*a cv=a*4 print('Area of the square:', dt) print('Perimeter of the square:', cv)
a=int(input('Enter one side of the square:')) dt=a*a cv=a*4 print(dt) print(cv)
a=int(input('Enter one side of the square:')) dt=a*a cv=a*4 print('Area of the square:') print('Perimeter of the square:')
Enter two positive integers a and b which are two sides of a rectangle. Print the area and perimeter of it.
a=float(input('Enter length:')) b=float(input('Enter width:')) s=a*b p=(a+b)*2 print('The area of the rectangle is:', s) print('The perimeter of the rectangle is:', p)
a=int(input('Enter length:')) b=int(input('Enter width:')) s=a*b p=(a+b)*2 print('The area of the rectangle is:', s) print('The perimeter of the rectangle is:', p)
Given the length and width of a rectangle, write a program to calculate its area and perimeter.
Area of the rectangle:
Perimeter of the rectangle:
Area:
Perimeter:
You have 3 types of banknotes: 500đ, 200đ, and 100đ. Write a program to find all combinations to make 1700đ using these banknotes.
500 notes: a; 200 notes: b; 100 notes: c;
500 notes: a; 200 notes: b; 100 notes: c;
a b c
500 notes:; 200 notes:; 100 notes:
There are 36 animals in total, consisting of chickens and dogs, with a total of 100 legs. How many chickens and how many dogs are there?
Number of chickens:
Number of dogs:
Chickens:
Dogs:
Write a function to perform a specific task.
Write a function that takes multiple numbers (integers or floats) from the keyboard, separated by spaces. Transfer these numbers into list A and print list B consisting of the even numbers from list A, calculate the sum and count the even numbers.
Write a program that requires input from the keyboard for a string of characters, then reports: The total number of characters that are digits in the string. The total number of characters that are English letters in the string. Write a function for each requirement.
Using a function, write a program that performs: Input two natural numbers from the keyboard, separated by spaces. Calculate and print the sum of these numbers. Input two natural numbers from the keyboard, separated by commas, and print the greatest common divisor of the two numbers.
Given the list A=[3, 2, 12, -34, 31, 7, -2]. Create list B consisting of even numbers, and list C consisting of odd numbers. Calculate the sum of even numbers, the sum of odd numbers, and count how many even and odd numbers there are.
Write a function that takes a full name (including last name, middle name, and first name) from the keyboard. Then print the last name, middle name, and first name in order. For example: Enter full name: Nguyen Hong Kim Hoa Last name: Nguyen Middle name: Hong Kim First name: Hoa
Write a function that takes n integers from the keyboard, separated by spaces. Then print on the screen: - The list of numbers entered in a single line - The largest number and the index of the largest number. - The smallest number and the index of the smallest number.
Write a program that performs the following tasks, each task needs to be performed by a function: - Input a sequence of integers from the keyboard, each number separated by spaces. Transfer these numbers into list A and print list A on the screen. - Extract from list A a list B consisting of even numbers. - Extract from list A a list C consisting of odd numbers.
