WorksheetsÔN TẬP CUỐI HỌC KÌ II
Total questions: 39
Worksheet time: 20mins
In the While statement, the loop block is executed until:
<đk>= False
<đk> = True
<kl>=True
<kl>= False
In the program, when encountering which command must it stop (even if it is in a loop)?
break
end
peat
reak
What is the meaning of the following program: k=2 while k<50: print(k) k=k+3
prints the sequence from 2 to less than 50, increasing by 3 each time.
prints the sequence less than 50, increasing by 3 each time.
prints the sequence outside 50, summing the elements of the sequence.
prints the sequence three times the sequence of 50.
What is the result of the following program: for k in range(10): print(k,end= “ ”) if k==5: break
0,1,2,3,4,5
0,1,2,3,4,5,6,7,8,9
0,1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9
What is the command to get the length of the list K?
len(K)
len[K]
len “K”
K.len()
Given the list H=[5,7,9,6,4], what is the command to access the element with the value 9 in that list H?
H[2]
H[3]
H[9]
H(2)
In a list, we can access each element of the list through:
index
value
list
command
In Python lists, the index in the list starts from:
0
1
-1
n
What is the command to check if the value 50 is in the list H=[10,20,30,40, 50]?
50 in H
50 on H
50 of H
50 test H
What is the meaning of the following command: H=[1,2,3,4] for k in H: print(k)
prints each element of the list H.
prints each position of the list H.
prints the sequence of characters k.
prints from 0 to the length of the list minus 1.
Assuming H=[“o”, “T”, 5, “7”, “k”], what is the result of the command: 7 in H?
False
True
7
“7”
Please identify which command deletes the entire list K:
K.clear()
clear(K)
K.remove(K)
K.remove[K]
Identify the command to delete the entire list K:
K.clear()
clear(K)
K.remove(K)
K.remove[K]
Choose the correct command to delete the first element with value 1 from the list K:
K.remove(1)
K.remove(K[1])
K.remove[1]
remove(K[1])
In Python, which command is used to calculate the length of the string s?
len(s)
length(s)
s.len()
s.length()
What is the length of the string '1234%^^%THINGSER'?
16
17
18
15
After executing the following command, what will the variable s contain? s1 = '3987343' s2 = '' for ch in s1: if int(ch) % 2 == 0: s2 = s2 + ch print(s2)
84
3987343
39873
343
What is the expression to check if
What is the command to find the position of a substring in another string?
find()
in()
search()
join()
Given the string s = 'abccabed'. What is the result after executing the command: s.find('abc', 3)?
-1
2
0
4
For the list k=['1','2','3','4'], what command gives the result '1,2,3,4'?
','.join(k)
' '.join(k)
','.split(k)
' '.join()
For s = 'Mùa hoa phượng đến rồi', what command gives the result list k=['Mùa','hoa','phượng','đến','rồi']?
k=s.split()
k:s.split()
k=split(s)
s.split(k)
What is the keyword to define a function?
def
fine
det
del
What is the result after executing the following code: def tong(x): return (x+1) print(tong(3))?
4
3
2
5
What is the correct syntax to call a function in Python?
When declaring a function, which component is defined and used as a variable within the function?
Parameter
Argument
Data
Value
When declaring a function, which component is defined and used as a variable in the function?
Parameter.
Argument.
Data.
Value.
Assuming function f has two parameters when declared. Which two argument values passed will cause an error?
10, c.
2, 3.
"a", "b".
"a", "3".
When calling function f(1, 2, 3), how many parameters are defined in function f?
3.
2.
1.
4.
What are the values of x, y when executing the following command: x = 3 y = 4 def f(x, y): x = x + y y = y + 2 return x print(f(x, y))
7, 4.
4, 6.
5, 4.
2, 3.
What is the result of the following program? >>>def f(a,b): return a + b + N >>> N = 5 >>>f(3, 3)
11.
6.
5.
The program has an error.
What error does the following program report? for i in range(10) print(i)
SyntaxError.
NameError.
Type Error.
ValueError.
What error does the following program report? n = 5 for i in range(n): prin(t)
NameError.
Type Error.
SyntaxError.
ValueError.
What error does the following program report? lst = [1, 2, 3, 4, 5] for i in range(10): print(lst[i])
IndexError.
NameError.
SyntaxError.
ValueError.
What is an exception error in Python?
An error when a command cannot be executed.
An error when accessing an undeclared variable.
An error when writing a statement with incorrect syntax.
An error when the program compiles to an exe file.
Which is not a tool for testing programs?
Data statistics tool.
Test data set generation tool.
Intermediate variable printing tool.
Breakpoint tool in programming software.
At which line does the following program have an error? >>> fruits = ['Banana', 'Apple', 'Lime'] >>> loud_fruits = [fruit.upper() for fruit in fruits] >>> print(loud_fruits) >>> list(enumerate(fruits))
No error occurs.
3.
4.
2
If the program runs with an error and the error message is ZeroDivisionError, what kind of error is it and how should you fix it? Choose the most correct option.
This is a division by zero error, you need to find out the cause of 0 appearing when dividing, you can add a check before performing the division.
This is a division by zero error, you need to remove this command from the program.
This is a division by zero error, you need to replace the operation with another one to avoid this error.
This is an error that cannot be fixed.
The program runs with a NameError exception, so which component should be checked?
the names of variables and functions.
the index in the array.
the value of the number being divided.
the data type of the input.
