Pearson Edexcel GCSE (9-1) · Computer Science (1CP2)

Subprograms:練習題

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

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

A programmer wants to break down a complex problem into smaller, manageable parts. What is a primary benefit of using subprograms for this purpose?

第 2 題
1

A function is defined as follows:
function calculate(a, b)
    return a * b + 2
endfunction

What is the output of print(calculate(3, 4))?

第 3 題
1

A subprogram is designed to update a user's score in a database but does not need to send any data back to the part of the program that called it. Which type of subprogram is this?

第 4 題
1

Which of the following describes the difference between a global variable and a local variable used within a subprogram?

第 5 題
1

Which of the following is a potential risk of using global variables instead of passing parameters to subprograms?

第 6 題
3

Explain why a programmer would use a function rather than a procedure when calculating the square root of a number.

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

第 7 題
5

A variable total is declared inside a subprogram. Explain the effect on the program if you attempt to access total from the main program block.

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

第 8 題
6

Describe two characteristics of a function that distinguish it from a procedure within the Pearson Edexcel PLS.

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

第 9 題
3

A program uses a subprogram to calculate the total price of items including tax. The subprogram takes the price as an input and returns the final value.

(a) Explain one benefit of using subprograms in this scenario.
(b) Define the difference between a parameter and an argument in the context of this subprogram.

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

第 10 題
6

Consider the following subprogram snippet:
FUNCTION calculate(a, b)
  global total
  total = a + b
  RETURN total * 2
ENDFUNCTION


(a) Distinguish between the local variables and global variables in this snippet.
(b) Explain one potential risk of using the global keyword inside a subprogram.
(c) Rewrite the subprogram so it does not use a global variable but still allows the calling program to use the sum.

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

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

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

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

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

立即練習