GCE O-Level · Computing (7155)

Testing and Debugging:練習題

5 條多項選擇題即時批改,另有 5 條文字題附完整解題步驟,全部圍繞「Testing and Debugging」。

10 條題目28 免費,無需登記
第 1 題
1

A programmer is checking if an input string code has a length of exactly 5 characters and contains only digits. Which validation technique is primarily being used for the length check?

第 2 題
1

A data validation routine checks if a value \(Y\) (Year of Birth) is within the valid range \(1900 \le Y \le 2024\). To perform boundary value analysis, which of the following sets of test data should be used to test the limits of this range check?

第 3 題
1

A programmer writes a script to calculate the square root of a user-provided number using math.sqrt(). If the user enters a negative number, the program immediately stops and displays a "ValueError". Which type of error does this represent?

第 4 題
1

Study the following Python code segment:

total = 0
for i in range(5):
  if i % 2 == 0:
    total = total + i

What is the final value of total after the loop finishes?

第 5 題
1

Consider the following Python code intended to sum all odd integers in the list vals = [1, 2, 3, 4, 5]:

total = 0
i = 0
while i <= len(vals):
  if vals[i] % 2 != 0:
    total += vals[i]
  i += 1

What will happen when this code is executed?

第 6 題
4

A programmer performs a manual dry run of the following algorithm using a trace table:
1. Set \(x = 10\)
2. For each \(i\) in the range from \(1\) to \(3\) (inclusive):
   a. \(x = x + i\)
What is the final value of \(x\) recorded in the trace table after the loop finishes?

先自己寫一次答案,再對照解題步驟。

第 7 題
5

A program is designed to validate a date string in the format "DD-MM". Describe how the program should sequentially use a length check, a format check, and range checks to ensure that a user input like "32-01" is rejected. Specify what each check would look for in this specific input.

先自己寫一次答案,再對照解題步驟。

第 8 題
4

A system requires a product code to follow the format of exactly three uppercase letters followed by exactly three digits (e.g., \(ABC123\)). A user enters \(AB1234\). Name two specific types of data validation checks that would detect this error and explain how each check would identify the mismatch.

先自己寫一次答案,再對照解題步驟。

第 9 題
4

A software developer is designing a validation routine for a new user account. The username must satisfy the following conditions: it must not be left blank, it must be between \(5\) and \(12\) characters long, and it must contain only alphanumeric characters.

(a) Identify the three specific types of data validation checks being used to enforce these conditions.
(b) For the length requirement (between \(5\) and \(12\) characters), provide one example of boundary test data and one example of invalid (error) test data.

先自己寫一次答案,再對照解題步驟。

第 10 題
6

Perform a manual dry run of the following algorithm using a trace table to identify duplicate adjacent numbers in a list.

Algorithm:
1. Set \(L = [5, 2, 8, 8, 3]\)
2. Set \(found = False\)
3. Set \(i = 0\)
4. While \(i < 4\) and \(found\) is \(False\):
    a. If \(L[i] == L[i+1]\):
        i. \(found = True\)
        ii. \(duplicate = L[i]\)
    b. \(i = i + 1\)

Provide a trace table showing the values of \(i\), \(L[i]\), \(L[i+1]\), and \(found\) at the start of each loop iteration until the algorithm terminates.

先自己寫一次答案,再對照解題步驟。

* thinka提供的內容由AI生成,可能並非總是準確或最新。請將其用作輔助資源,並與官方材料進行核實。

你已看過標準答案,接下來輪到批改你的答案。

這一頁可以告訴你好答案的樣子,卻無法指出你的答案欠缺什麼。thinka 按真實評分準則批改你的文字答案,約 15 秒完成。

想多做幾條同類題目?立即開始練習呢個課題,即做即批改。

立即練習