Đề Thi FE PFP191 - SP26 - B5 - FE - RE

adminadmin is verified member.

Member
Thành viên BQT
Administrator
Học kỳ
SP2026
Thời Gian
3/5/26
Loại tài liệu
FE
PFP191 SP26 B5 FE RE

Câu 1: Choose 1 answer Multiple Choice

Python

<span><span>class</span> <span>Dog</span>:</span><br> <span><span>def</span> <span>__init__</span>(<span>self, name, age</span>):</span><br> self.name = name<br> self.age = age<br>
The correct way to instantiate the above Dog class is:

  • A. Dog()
  • B. Dog("Rufus", 3)
  • C. Dog.create("Rufus", 3)
  • D. Dog__init__("Rufus", 3)

    Đáp án: B
Câu 2: Choose 1 answer Multiple Choice
Which of the following is rarely used in Object Oriented Programming?

  • A. Method
  • B. Constructor
  • C. Attribute
  • D. Destructor

    Đáp án: D
Câu 3: Choose 1 answer Multiple Choice

Which of the following statements is true about classes?

  • A. Classes cannot inherit from other classes.
  • B. Classes can contain both attributes and methods.
  • C. Every class must have at least one attribute.
  • D. Classes cannot create instances.

    Đáp án: B
Câu 4: Choose 1 answer Multiple Choice
What is the result of this code?

Python

<span><span>class</span> <span>A</span>:</span><br> <span><span>def</span> <span>show</span>(<span>self</span>):</span><br> print(<span>"A"</span>)<br><span><span>class</span> <span>B</span>(<span>A</span>):</span><br> <span>pass</span><br><span><span>class</span> <span>C</span>(<span>B</span>):</span><br> <span>pass</span><br>obj = C()<br>obj.show()<br>
  • A. "A"
  • B. "B"
  • C. "C"
  • D. Error

    Đáp án: A
Câu 5: Choose 1 answer Multiple Choice
In Python, a function within a class definition is called a:

  • A. a method
  • B. a class function
  • C. an operation
  • D. a factory

    Đáp án: A




Câu 6: Choose 1 answer Multiple Choice






What does the @property decorator do in Python?

  • A. Converts a function into a read-only attribute
  • B. Hides a method from the user
  • C. Makes a function private
  • D. Creates a new class

    Đáp án: A




Câu 7: Choose 1 answer Multiple Choice






What will be the output of this code?

Python

<span><span>class</span> <span>A</span>:</span><br> <span><span>def</span> <span>__init__</span>(<span>self</span>):</span><br> print(<span>"A constructor"</span>)<br><span><span>class</span> <span>B</span>(<span>A</span>):</span><br> <span><span>def</span> <span>__init__</span>(<span>self</span>):</span><br> print(<span>"B constructor"</span>)<br>obj = B()<br>
  • A. A constructor
  • B. B constructor
  • C. A constructor B constructor
  • D. Error

    Đáp án: B




Câu 8: Choose 1 answer Multiple Choice






What will be the output of this code?

Python

<span><span>class</span> <span>Student</span>:</span><br> <span><span>def</span> <span>__init__</span>(<span>self, name</span>):</span><br> self.name = name<br>s = Student(<span>"Alice"</span>)<br>print(s.name)<br>
  • A. Alice
  • B. Error
  • C. None
  • D. s.name

    Đáp án: A




Câu 9: Choose 1 answer Multiple Choice






In Object Oriented Programming, what is another name for the "attributes" of an object?

  • A. forms
  • B. methods
  • C. portions
  • D. messages
  • E. fields

    Đáp án: E




Câu 10: Choose 1 answer Multiple Choice






What is the output of the following snippet code?

Python

sentence = <span>"This-is;a-test"</span><br>words = sentence.split(<span>'-;'</span>)<br>print(words)<br>
  • A. ['This-is;a-test']
  • B. ['This' 'is' 'a' 'test']
  • C. This, is, a, test
  • D. This is a test

    Đáp án: A




Câu 11: Choose 1 answer Multiple Choice






What will be the output of the following code?

Python

s = <span>"abracadabra"</span><br>print(s.rindex(<span>"a"</span>))<br>
  • A. 10
  • B. 3
  • C. 5
  • D. 0

    Đáp án: A




Câu 12: Choose 1 answer Multiple Choice






What is the result of 'abcde'.find('c')?

  • A. 1
  • B. 2
  • C. 3
  • D. -1

    Đáp án: B




Câu 13: Choose 1 answer Multiple Choice






Python strings have a property called "immutability." What does this mean?

  • A. Strings can't be divided by numbers
  • B. Strings in Python can't be changed
  • C. Strings in Python can be represented as arrays of chars
  • D. You can update a string in Python with concatenation

    Đáp án: B




Câu 14: Choose 1 answer Multiple Choice






Which method removes all whitespace from the beginning and end of a string?

  • A. strip()
  • B. trim()
  • C. clean()
  • D. remove()

    Đáp án: A




Câu 15: Choose 1 answer Multiple Choice






How can you efficiently check and count each word from a file without causing a KeyError if the word is not already in the dictionary?

  • A. Use if-else to check presence of word
  • B. Use dict[word] += 1 without checking
  • C. Use dict.get(word, 0) + 1
  • D. Use dict.setdefault(word, 0) + 1

    Đáp án: C




Câu 16: Choose 1 answer Multiple Choice






What happens if you access a non-existing key in a dictionary using square brackets (dict[key])?

  • A. Returns None
  • B. Raises a KeyError
  • C. Adds the key with None as its value
  • D. Returns 0

    Đáp án: B




Câu 17: Choose 1 answer Multiple Choice






What does the following Python code print out?

Python

a = [<span>1</span>, <span>2</span>, <span>3</span>, <span>8</span>]<br>b = [<span>4</span>, <span>5</span>, <span>6</span>]<br>c = a + b<br>print(c)<br>
  • A. 28
  • B. [1, 2, 3, 8, 4, 5, 6]
  • C. It raises an exception
  • D. 7

    Đáp án: B




Câu 18: Choose 1 answer Multiple Choice






What does file.write("text") return?

  • A. None
  • B. The number of characters written
  • C. The written string
  • D. Raises an error

    Đáp án: B




Câu 19: Choose 1 answer Multiple Choice






Which method in Python is used to read a single line from a text file?

  • A. readline()
  • B. read()
  • C. readlines()
  • D. getline()

    Đáp án: A




Câu 20: Choose 1 answer Multiple Choice






What is stored in a "file handle" that is returned from a successful open() call?

  • A. The handle is a connection to the file's data
  • B. The handle contains the first 10 lines of a file
  • C. All the data from the file is read into memory and stored in the handle
  • D. The handle has a list of all of the files in a particular folder on the hard drive

    Đáp án: A




Câu 21: Choose 1 answer Multiple Choice






The readlines() method returns...

  • A. str
  • B. a list of lines
  • C. a list of single characters
  • D. a list of integers

    Đáp án: B




Câu 22: Choose 1 answer Multiple Choice






What is the last action that must be performed on a file?

  • A. Close
  • B. Save
  • C. End
  • D. Write

    Đáp án: A




Câu 23: Choose 1 answer Multiple Choice






How does the 'open' function work in Python?

  • A. It basically takes the name of a file as an argument and returns a file handle which can be used to perform operations on the file.
  • B. It examines a program and analyses the syntactic structure.
  • C. It iterates through the items in a sequence, performing a similar operation on each.
  • D. It takes a format string and a tuple and generates a string that includes the elements of the tuple formatted as specified by the format string.

    Đáp án: A




Câu 24: Choose 1 answer Multiple Choice






What does the code below mean? f = open("test.txt")

  • A. Open the file test.txt with read and write permissions.
  • B. Open the file test.txt with read-only permission.
  • C. Open the file test.txt and allow overwriting the file.
  • D. Open the file test.txt and allow appending to the file.

    Đáp án: B




Câu 25: Choose 1 answer Multiple Choice






Which of the following CANNOT be variable names or identifiers in Python programming?

  • A. while
  • B. if
  • C. and
  • D. All of the above

    Đáp án: D




Câu 26: Choose 1 answer Multiple Choice






What is a reserved word in Python?

  • A. A word created by the programmer and assigned to a variable.
  • B. A word that has one specific meaning to Python and cannot be used as a variable name.
  • C. The name of a function available in Python.
  • D. A slang term for especially well-written code.

    Đáp án: B




Câu 27: Choose 1 answer Multiple Choice






Which of the following slicing operations will produce the list [12, 3]?

t = [9, 41, 12, 3, 74, 15]

  • A. t[12:3]
  • B. t[2:4]
  • C. t[2:2]
  • D. t[1:3]

    Đáp án: B




Câu 28: Choose 1 answer Multiple Choice






Which of the parts of a computer actually executes the program instructions?

  • A. RAM
  • B. CPU
  • C. Input/Output Devices
  • D. Secondary Memory

    Đáp án: B




Câu 29: Choose 1 answer Multiple Choice






What will happen if a string contains non-numeric characters and is converted using int()?

  • A. It will return 0
  • B. It will be converted to a float
  • C. It will raise a ValueError
  • D. It will be converted to a boolean

    Đáp án: C




Câu 30: Choose 1 answer Multiple Choice






How can you use list comprehension to create a list of even numbers from 1 to 10?

  • A. [x for x in range(1, 11) if x % 2 == 0]
  • B. [2*x for x in range(1, 6)]
  • C. [x*2 for x in range(10)]
  • D. [x for x in range(1, 11) when x % 2 == 0]

    Đáp án: A




Câu 31: Choose 1 answer Multiple Choice






What does the following Python code print out?

Python

a = [<span>1</span>, <span>2</span>, <span>3</span>]<br>b = [<span>4</span>, <span>5</span>, <span>6</span>]<br>c = a + b<br>print(<span>len</span>(c))<br>
  • A. 21
  • B. [4, 5, 6]
  • C. 15
  • D. 6

    Đáp án: D




Câu 32: Choose 1 answer Multiple Choice






Which of the following methods does not exist for tuples?

  • A. count()
  • B. index()
  • C. sort()
  • D. len()

    Đáp án: C




Câu 33: Choose 1 answer Multiple Choice






What is a function argument?

  • A. A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.
  • B. A way of calculating the result
  • C. The result of a function
  • D. A section of code that represents a command or action

    Đáp án: A




Câu 34: Choose 1 answer Multiple Choice






Consider the following function in Python:

Python

<span><span>def</span> <span>func</span>(<span>n</span>):</span><br> <span>while</span> n &gt; <span>0</span>:<br> print(n, end=<span>' '</span>)<br> n = n - <span>2</span><br>
What happens when the parameter n passed to the function is initially a positive odd number?

  • A. The function will enter an infinite loop.
  • B. The function will print numbers in reverse order until a negative number is reached.
  • C. The function will print numbers in reverse order until 1 is reached.
  • D. The function will not execute and return immediately.

    Đáp án: A




Câu 35: Choose 1 answer Multiple Choice






What is the flow of execution in a program?

  • A. The order in which statements are executed
  • B. The sequence in which functions are defined
  • C. The process of converting data types
  • D. The way parameters are passed to functions

    Đáp án: A




Câu 36: Choose 1 answer Multiple Choice






Which of the following reserved keyword is used to end a function, return generator?

  • A. break
  • B. switch
  • C. Return
  • D. yield

    Đáp án: D




Câu 37: Choose 1 answer Multiple Choice






What is the output of the following code snippet?

Python

num = <span>4</span><br>result = <span>1</span><br><span>while</span> num &gt; <span>1</span>:<br> result *= num<br> num -= <span>1</span><br>print(result)<br>
  • A. 24
  • B. 12
  • C. 10
  • D. 26

    Đáp án: A




Câu 38: Choose 1 answer Multiple Choice






What is the extend() method used for?

  • A. Adds an element to the end of a list.
  • B. Concatenates two lists, adding all the elements of the given list to the current list.
  • C. Replaces an element at a given position in the list.
  • D. Returns a copy of the current list.

    Đáp án: B




Câu 39: Choose 1 answer Multiple Choice






Which collection is ordered, changeable, and allows duplicate members?

  • A. SET
  • B. DICTIONARY
  • C. TUPLE
  • D. LIST

    Đáp án: D




Câu 40: Choose 1 answer Multiple Choice






What is the result of:

Python

a = [<span>1</span>, <span>2</span>, <span>3</span>]<br>a[<span>0</span>:<span>2</span>] = [<span>5</span>]<br>print(a)<br>
  • A. [5, 3]
  • B. [1, 2, 5]
  • C. [5, 2, 3]
  • D. [1, 5, 3]

    Đáp án: A




Câu 41: Choose 1 answer Multiple Choice






Which of the following elements of a mathematical expression in Python is evaluated last?

  • A. Addition
  • B. Multiplication
  • C. Parentheses
  • D. Division

    Đáp án: A




Câu 42: Choose 1 answer Multiple Choice






In the following code, print(98.6). What is "98.6"?

  • A. A conditional statement
  • B. A constant
  • C. An iteration / loop statement
  • D. A variable

    Đáp án: B




Câu 43: Choose 1 answer Multiple Choice






What is the primary function of the 'input' function in Python programs?

  • A. To output data to the console
  • B. To take user input as a string
  • C. To display user inputs
  • D. To define variables

    Đáp án: B




Câu 44: Choose 1 answer Multiple Choice






What will be the output of the following code snippet?

print(23 + (5 + 6)(1 + 1))

  • A. 129
  • B. 8
  • C. 121
  • D. None of the above

    Đáp án: A




Câu 45: Choose 1 answer Multiple Choice






What will be the output of the following code?

Python

x = <span>5</span><br>y = <span>10</span><br>print(x * y + x / y)<br>
  • A. 50.5
  • B. 55.5
  • C. 50.1
  • D. 51.0

    Đáp án: A




Câu 46: Choose 1 answer Multiple Choice






What does the term "algorithm" mean in the context of programming?

  • A. A high-level programming language
  • B. A step-by-step procedure or formula for solving a problem
  • C. A reserved keyword in Python
  • D. The output of a program

    Đáp án: B




Câu 47: Choose 1 answer Multiple Choice






Which of the following variable names are invalid?

  • A. _
  • B. 0
  • C. 0_
  • D. 0
  • E. for_
  • F. forĐáp án: C (Dựa trên hình ảnh có dấu tích ở C, nhưng thực tế cả B, C, D, F đều có vấn đề trong Python tùy ngữ cảnh; trong tài liệu chọn C)


Câu 48: Choose 1 answer Multiple Choice






Which of the following options correctly represents the precedence of the logical operators and, or, and NOT in Python, from highest to lowest?

  • A. not, and, or
  • B. or, and, not
  • C. and, or, not
  • D. not, or, and

    Đáp án: A




Câu 49: Choose 1 answer Multiple Choice






Which logical operator is used to combine multiple conditions and returns True if all conditions are True?

  • A. and
  • B. or
  • C. xor
  • D. not

    Đáp án: A




Câu 50: Choose 1 answer Multiple Choice






Assume we have the file.txt contains:

"for line in hand:

count = count + 1

print('Line Count:', count)"

What happens with the following code?

Python

f = <span>open</span>(<span>"file.txt"</span>)<br>print(<span>len</span>(f.readlines()))<br>
  • A. 0
  • B. 1
  • C. 3
  • D. Error

    Đáp án: C
 

Đính kèm

  • PFP191 SP26 B5 FE RE_001.webp
    PFP191 SP26 B5 FE RE_001.webp
    48.5 KB · Lượt xem: 4
  • PFP191 SP26 B5 FE RE_002.webp
    PFP191 SP26 B5 FE RE_002.webp
    34.9 KB · Lượt xem: 4
  • PFP191 SP26 B5 FE RE_003.webp
    PFP191 SP26 B5 FE RE_003.webp
    55.8 KB · Lượt xem: 1
  • PFP191 SP26 B5 FE RE_004.webp
    PFP191 SP26 B5 FE RE_004.webp
    40 KB · Lượt xem: 1
  • PFP191 SP26 B5 FE RE_005.webp
    PFP191 SP26 B5 FE RE_005.webp
    32.5 KB · Lượt xem: 1
  • PFP191 SP26 B5 FE RE_006.webp
    PFP191 SP26 B5 FE RE_006.webp
    46 KB · Lượt xem: 1
  • PFP191 SP26 B5 FE RE_007.webp
    PFP191 SP26 B5 FE RE_007.webp
    49.5 KB · Lượt xem: 1
  • PFP191 SP26 B5 FE RE_008.webp
    PFP191 SP26 B5 FE RE_008.webp
    41.3 KB · Lượt xem: 1
  • PFP191 SP26 B5 FE RE_009.webp
    PFP191 SP26 B5 FE RE_009.webp
    33.8 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_010.webp
    PFP191 SP26 B5 FE RE_010.webp
    45.8 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_011.webp
    PFP191 SP26 B5 FE RE_011.webp
    30.7 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_012.webp
    PFP191 SP26 B5 FE RE_012.webp
    22.2 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_013.webp
    PFP191 SP26 B5 FE RE_013.webp
    60.2 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_014.webp
    PFP191 SP26 B5 FE RE_014.webp
    31.9 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_015.webp
    PFP191 SP26 B5 FE RE_015.webp
    43.8 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_016.webp
    PFP191 SP26 B5 FE RE_016.webp
    37.1 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_017.webp
    PFP191 SP26 B5 FE RE_017.webp
    37.2 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_018.webp
    PFP191 SP26 B5 FE RE_018.webp
    34 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_019.webp
    PFP191 SP26 B5 FE RE_019.webp
    33.5 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_020.webp
    PFP191 SP26 B5 FE RE_020.webp
    63.6 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_021.webp
    PFP191 SP26 B5 FE RE_021.webp
    30.5 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_022.webp
    PFP191 SP26 B5 FE RE_022.webp
    28.7 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_023.webp
    PFP191 SP26 B5 FE RE_023.webp
    65.4 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_024.webp
    PFP191 SP26 B5 FE RE_024.webp
    60 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_025.webp
    PFP191 SP26 B5 FE RE_025.webp
    31.6 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_026.webp
    PFP191 SP26 B5 FE RE_026.webp
    52.1 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_027.webp
    PFP191 SP26 B5 FE RE_027.webp
    34.9 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_028.webp
    PFP191 SP26 B5 FE RE_028.webp
    36.9 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_029.webp
    PFP191 SP26 B5 FE RE_029.webp
    41.1 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_030.webp
    PFP191 SP26 B5 FE RE_030.webp
    44 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_031.webp
    PFP191 SP26 B5 FE RE_031.webp
    32.7 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_032.webp
    PFP191 SP26 B5 FE RE_032.webp
    30.5 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_033.webp
    PFP191 SP26 B5 FE RE_033.webp
    45.4 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_034.webp
    PFP191 SP26 B5 FE RE_034.webp
    68 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_035.webp
    PFP191 SP26 B5 FE RE_035.webp
    53.3 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_036.webp
    PFP191 SP26 B5 FE RE_036.webp
    31.6 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_037.webp
    PFP191 SP26 B5 FE RE_037.webp
    36.3 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_038.webp
    PFP191 SP26 B5 FE RE_038.webp
    50.6 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_039.webp
    PFP191 SP26 B5 FE RE_039.webp
    33.7 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_040.webp
    PFP191 SP26 B5 FE RE_040.webp
    28 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_041.webp
    PFP191 SP26 B5 FE RE_041.webp
    33.7 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_042.webp
    PFP191 SP26 B5 FE RE_042.webp
    37.3 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_043.webp
    PFP191 SP26 B5 FE RE_043.webp
    44.4 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_044.webp
    PFP191 SP26 B5 FE RE_044.webp
    33.8 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_045.webp
    PFP191 SP26 B5 FE RE_045.webp
    30.7 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_046.webp
    PFP191 SP26 B5 FE RE_046.webp
    53.5 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_047.webp
    PFP191 SP26 B5 FE RE_047.webp
    27 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_048.webp
    PFP191 SP26 B5 FE RE_048.webp
    34.3 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_049.webp
    PFP191 SP26 B5 FE RE_049.webp
    27 KB · Lượt xem: 0
  • PFP191 SP26 B5 FE RE_050.webp
    PFP191 SP26 B5 FE RE_050.webp
    47 KB · Lượt xem: 4

Tạo tài khoản hoặc đăng nhập để bình luận

Bạn phải là thành viên mới có thể bình luận.

Tạo tài khoản

Hãy tạo tài khoản trên cộng đồng của chúng tôi. Thật dễ dàng!

Đăng nhập

Bạn đã có tài khoản? Đăng nhập tại đây.

Back
Top