Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

ÔN TẬP CUỐI HỌC KÌ II

Total questions: 39

Worksheet time: 20mins

Name
Class
Date
1.

In the While statement, the loop block is executed until:

a)

<đk>= False

b)

<đk> = True

c)

<kl>=True

d)

<kl>= False

2.

In the program, when encountering which command must it stop (even if it is in a loop)?

a)

break

b)

end

c)

peat

d)

reak

3.

What is the meaning of the following program: k=2 while k<50: print(k) k=k+3

a)

prints the sequence from 2 to less than 50, increasing by 3 each time.

b)

prints the sequence less than 50, increasing by 3 each time.

c)

prints the sequence outside 50, summing the elements of the sequence.

d)

prints the sequence three times the sequence of 50.

4.

What is the result of the following program: for k in range(10): print(k,end= “ ”) if k==5: break

a)

0,1,2,3,4,5

b)

0,1,2,3,4,5,6,7,8,9

c)

0,1,2,3,4,5,6,7,8,9,10

d)

1,2,3,4,5,6,7,8,9

5.

What is the command to get the length of the list K?

a)

len(K)

b)

len[K]

c)

len “K”

d)

K.len()

6.

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?

a)

H[2]

b)

H[3]

c)

H[9]

d)

H(2)

7.

In a list, we can access each element of the list through:

a)

index

b)

value

c)

list

d)

command

8.

In Python lists, the index in the list starts from:

a)

0

b)

1

c)

-1

d)

n

9.

What is the command to check if the value 50 is in the list H=[10,20,30,40, 50]?

a)

50 in H

b)

50 on H

c)

50 of H

d)

50 test H

10.

What is the meaning of the following command: H=[1,2,3,4] for k in H: print(k)

a)

prints each element of the list H.

b)

prints each position of the list H.

c)

prints the sequence of characters k.

d)

prints from 0 to the length of the list minus 1.

11.

Assuming H=[“o”, “T”, 5, “7”, “k”], what is the result of the command: 7 in H?

a)

False

b)

True

c)

7

d)

“7”

12.

Please identify which command deletes the entire list K:

a)

K.clear()

b)

clear(K)

c)

K.remove(K)

d)

K.remove[K]

13.

Identify the command to delete the entire list K:

a)

K.clear()

b)

clear(K)

c)

K.remove(K)

d)

K.remove[K]

14.

Choose the correct command to delete the first element with value 1 from the list K:

a)

K.remove(1)

b)

K.remove(K[1])

c)

K.remove[1]

d)

remove(K[1])

15.

In Python, which command is used to calculate the length of the string s?

a)

len(s)

b)

length(s)

c)

s.len()

d)

s.length()

16.

What is the length of the string '1234%^^%THINGSER'?

a)

16

b)

17

c)

18

d)

15

17.

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)

a)

84

b)

3987343

c)

39873

d)

343

18.

What is the expression to check if is in ?

a)

in

b)

in

c)

.find()

d)

.find()

19.

What is the command to find the position of a substring in another string?

a)

find()

b)

in()

c)

search()

d)

join()

20.

Given the string s = 'abccabed'. What is the result after executing the command: s.find('abc', 3)?

a)

-1

b)

2

c)

0

d)

4

21.

For the list k=['1','2','3','4'], what command gives the result '1,2,3,4'?

a)

','.join(k)

b)

' '.join(k)

c)

','.split(k)

d)

' '.join()

22.

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']?

a)

k=s.split()

b)

k:s.split()

c)

k=split(s)

d)

s.split(k)

23.

What is the keyword to define a function?

a)

def

b)

fine

c)

det

d)

del

24.

What is the result after executing the following code: def tong(x): return (x+1) print(tong(3))?

a)

4

b)

3

c)

2

d)

5

25.

What is the correct syntax to call a function in Python?

a)

()

b)

.()

c)

[]

d)

=()

26.

When declaring a function, which component is defined and used as a variable within the function?

a)

Parameter

b)

Argument

c)

Data

d)

Value

27.

When declaring a function, which component is defined and used as a variable in the function?

a)

Parameter.

b)

Argument.

c)

Data.

d)

Value.

28.

Assuming function f has two parameters when declared. Which two argument values passed will cause an error?

a)

10, c.

b)

2, 3.

c)

"a", "b".

d)

"a", "3".

29.

When calling function f(1, 2, 3), how many parameters are defined in function f?

a)

3.

b)

2.

c)

1.

d)

4.

30.

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))

a)

7, 4.

b)

4, 6.

c)

5, 4.

d)

2, 3.

31.

What is the result of the following program? >>>def f(a,b): return a + b + N >>> N = 5 >>>f(3, 3)

a)

11.

b)

6.

c)

5.

d)

The program has an error.

32.

What error does the following program report? for i in range(10) print(i)

a)

SyntaxError.

b)

NameError.

c)

Type Error.

d)

ValueError.

33.

What error does the following program report? n = 5 for i in range(n): prin(t)

a)

NameError.

b)

Type Error.

c)

SyntaxError.

d)

ValueError.

34.

What error does the following program report? lst = [1, 2, 3, 4, 5] for i in range(10): print(lst[i])

a)

IndexError.

b)

NameError.

c)

SyntaxError.

d)

ValueError.

35.

What is an exception error in Python?

a)

An error when a command cannot be executed.

b)

An error when accessing an undeclared variable.

c)

An error when writing a statement with incorrect syntax.

d)

An error when the program compiles to an exe file.

36.

Which is not a tool for testing programs?

a)

Data statistics tool.

b)

Test data set generation tool.

c)

Intermediate variable printing tool.

d)

Breakpoint tool in programming software.

37.

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))

a)

No error occurs.

b)

3.

c)

4.

d)

2

38.

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.

a)

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.

b)

This is a division by zero error, you need to remove this command from the program.

c)

This is a division by zero error, you need to replace the operation with another one to avoid this error.

d)

This is an error that cannot be fixed.

39.

The program runs with a NameError exception, so which component should be checked?

a)

the names of variables and functions.

b)

the index in the array.

c)

the value of the number being divided.

d)

the data type of the input.