An original Thinka practice paper modelled on the structure and difficulty of the Jun 2023 (V3) Cambridge IGCSE Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
卷一 Computer Systems
Answer all questions. Calculators must not be used.
11 题目 · 77 分
题目 1 · Short/Medium Answer
7 分
An 8-bit unsigned binary register contains the value 11010100. (a) Convert the binary number to denary. (b) Convert the binary number to hexadecimal. (c) A logical right shift of two places is performed on the binary register. Explain the effect of this shift on the original value.
查看答案详解收起答案详解
解题
(a) Convert 11010100 to denary: 128 + 64 + 16 + 4 = 212. (b) Split into nibbles: 1101 (= 13 = D) and 0100 (= 4). Hexadecimal is D4. (c) Shift 11010100 right by 2 places: 00110101 (53 in denary). This halves the value twice (divides by 4).
评分标准
(a) 1 mark for correct denary conversion (212). (b) 2 marks for correct hexadecimal conversion: 1 mark for 'D', 1 mark for '4'. (c) 3 marks: 1 mark for stating the resulting binary number (00110101); 1 mark for stating the value is divided by 4; 1 mark for stating that the two least significant bits are lost.
题目 2 · Short/Medium Answer
7 分
During the execution of a program, the central processing unit (CPU) carries out the fetch-decode-execute cycle. (a) State the name of the register that holds the current instruction while it is being decoded. (b) Describe the role of the Memory Address Register (MAR) during the fetch stage. (c) Explain how the width of the address bus can affect the performance of a computer system.
查看答案详解收起答案详解
解题
(a) Current Instruction Register (CIR) (b) During fetch, the address in the Program Counter (PC) is copied to the MAR. The MAR then sends this address down the address bus to memory. (c) Bus width determines the memory space. A wider address bus allows a computer to address more bytes of RAM.
评分标准
(a) 1 mark for Current Instruction Register (CIR). (b) Max 3 marks: 1 mark for holding the address of instruction/data to be fetched; 1 mark for receiving the address from the Program Counter (PC); 1 mark for sending the address via the address bus to memory. (c) Max 3 marks: 1 mark for more unique memory addresses; 1 mark for supporting more physical RAM; 1 mark for reducing performance bottlenecks from virtual memory.
题目 3 · Short/Medium Answer
7 分
Devices connected to the Internet use both Media Access Control (MAC) addresses and Internet Protocol (IP) addresses. (a) Explain two differences between a MAC address and an IP address. (b) A company installs a new router in their local area network. Describe the role of this router in managing data traffic.
查看答案详解收起答案详解
解题
(a) MAC is 48-bit (or 64-bit) written in hex and physical. IP is 32-bit (IPv4) or 128-bit (IPv6) and logical. (b) A router connects networks together and forwards packets of data from one network to another by checking IP addresses.
评分标准
(a) Max 4 marks: 2 marks for Difference 1 (MAC is permanent/manufacturer-assigned vs IP is temporary/network-assigned); 2 marks for Difference 2 (MAC identifies the physical interface vs IP identifies the network location). (b) Max 3 marks: 1 mark for forwarding data packets between networks; 1 mark for inspecting the destination IP address; 1 mark for using routing tables to find the optimal path.
题目 4 · Short/Medium Answer
7 分
A software developer writes a program in a high-level programming language. (a) Describe how a compiler translates this high-level code. (b) Identify two advantages of using an interpreter instead of a compiler during the development phase of a program. (c) State why low-level code might still be used by system programmers.
查看答案详解收起答案详解
解题
(a) Compilers take the whole source code file and produce an executable machine code. (b) Interpreters translate line-by-line, showing errors immediately. (c) Assembly/machine code is used for device drivers and embedded systems where hardware control and performance are critical.
评分标准
(a) Max 3 marks: 1 mark for translating the entire program at once; 1 mark for producing an independent executable file; 1 mark for generating a list of errors at the end of compilation. (b) Max 2 marks: 1 mark for immediate error detection during testing; 1 mark for skipping compilation time for rapid testing. (c) Max 2 marks: 1 mark for direct control of hardware / CPU registers; 1 mark for memory efficiency / faster execution speed.
题目 5 · Short/Medium Answer
7 分
The internet exposes computer systems to various security threats. (a) Identify two differences between phishing and pharming. (b) Explain how the use of firewalls can protect a computer network from unauthorized access. (c) State the purpose of anti-spyware software.
查看答案详解收起答案详解
解题
(a) Phishing is email-based; pharming is DNS/server-based redirection. (b) Firewalls examine traffic packets and apply rules to reject malicious payloads. (c) Anti-spyware prevents keyloggers and covert data-gathering tools from compromising privacy.
评分标准
(a) Max 3 marks: 1 mark for phishing using deceptive emails/links; 1 mark for pharming modifying DNS/installing local malware; 1 mark for pharming not requiring a user to click an email link to be redirected. (b) Max 3 marks: 1 mark for monitoring/filtering incoming and outgoing traffic; 1 mark for checking traffic against predefined security rules; 1 mark for blocking unauthorized access or warning users. (c) 1 mark for detecting and deleting keyloggers/spyware to protect sensitive credentials.
题目 6 · Short/Medium Answer
7 分
An automated temperature monitoring and ventilation system is designed for a large indoor greenhouse. (a) Identify one sensor and one actuator that would be required for this automated system to operate. (b) Describe how the sensor, microprocessor, and actuator work together to regulate the temperature inside the greenhouse.
查看答案详解收起答案详解
解题
(a) Temperature sensor and an electric motor/fan. (b) Readings are digitized, evaluated by a microprocessor, and if outside bounds, a control signal is sent to the actuator to cool/heat the greenhouse in a continuous cycle.
评分标准
(a) 2 marks: 1 mark for Temperature sensor; 1 mark for a valid actuator (e.g., motor, fan, heater). (b) Max 5 marks: 1 mark for sensor sending continuous physical data; 1 mark for analogue-to-digital conversion (ADC); 1 mark for microprocessor comparing data to preset values; 1 mark for microprocessor sending a signal to the actuator if thresholds are crossed; 1 mark for continuous feedback loop.
题目 7 · Short/Medium Answer
7 分
A computer operating system manages memory, files, and handles hardware interrupts. (a) Define the term 'interrupt'. (b) Identify one hardware event and one software event that could generate an interrupt. (c) Explain how the operating system handles an interrupt when it is received.
查看答案详解收起答案详解
解题
(a) An interrupt suspends program execution to deal with an external request. (b) Hardware: key press. Software: arithmetic error. (c) Save state -> run ISR -> restore state.
评分标准
(a) Max 2 marks: 1 mark for a signal sent to the CPU; 1 mark for suspending current program execution. (b) 2 marks: 1 mark for a valid hardware event; 1 mark for a valid software event. (c) Max 3 marks: 1 mark for saving current register states/CPU status; 1 mark for calling/executing the Interrupt Service Routine (ISR); 1 mark for restoring previous state and resuming the interrupted task.
题目 8 · Short/Medium Answer
7 分
A logic circuit has three inputs: A, B, and C. The logic expression for the output X is: X = (A AND B) OR (NOT B AND C). (a) Complete the truth table for output X. (b) Identify the single logic gate that produces an output of 0 only when both of its inputs are 1.
查看答案详解收起答案详解
解题
(a) Evaluated rows: Row 000: 0 OR 0 = 0; Row 001: 0 OR 1 = 1; Row 010: 0 OR 0 = 0; Row 011: 0 OR 0 = 0; Row 100: 0 OR 0 = 0; Row 101: 0 OR 1 = 1; Row 110: 1 OR 0 = 1; Row 111: 1 OR 0 = 1. (b) NAND gate produces 0 only when both inputs are 1, otherwise 1.
评分标准
(a) Max 5 marks: 1 mark for every 2 correct outputs in the truth table. (b) 2 marks for identifying the NAND gate (1 mark for gate name, 1 mark for matching logic description).
题目 9 · Short/Medium Answer
7 分
Data is encrypted before it is transmitted over the internet to keep it secure. One method of encryption is symmetric encryption.
(a) Describe how symmetric encryption is used to secure data. [3]
(b) Another method of encryption is asymmetric encryption. Explain how asymmetric encryption works and why it is more secure than symmetric encryption for transmitting data. [4]
查看答案详解收起答案详解
解题
(a) Symmetric encryption: 1. Plain text is converted into cipher text using an encryption key and an algorithm. 2. The same key is used by both the sender to encrypt and the receiver to decrypt the data. 3. The key must be transmitted securely between both parties, which is a potential vulnerability.
(b) Asymmetric encryption: 1. It utilizes two different but mathematically linked keys: a public key and a private key. 2. The public key is made available to anyone and is used to encrypt the plain text into cipher text. 3. Only the private key, kept secret by the owner, can decrypt this cipher text back into plain text. 4. It is more secure than symmetric encryption because the private decryption key is never transmitted over the internet, eliminating the risk of it being intercepted.
评分标准
(a) Max 3 marks: - Plain text is converted to cipher text using an encryption key/algorithm (1) - The same/identical key is used to both encrypt and decrypt the data (1) - The key must be shared / sent from the sender to the receiver (1) - If the key is intercepted, unauthorized users can decrypt the data (1) - Receiver uses the shared key to decrypt the cipher text back into plain text (1)
(b) Max 4 marks: - Uses a key pair // uses a public key and a private key (1) - The public key and private key are mathematically linked (1) - The public key is shared openly and is used by the sender to encrypt the data (1) - The private key is kept secret by the receiver and is used to decrypt the data (1) - It is more secure because the private key never needs to be transmitted over the network (1) - This prevents the interception of the decryption key during transmission (1)
题目 10 · Short/Medium Answer
7 分
A computer system is based on the Von Neumann architecture.
(a) Identify the register in the CPU that holds the address of the next instruction to be fetched. [1]
(b) Describe the role of the Program Counter (PC) and the Memory Address Register (MAR) during the fetch stage of the fetch-decode-execute cycle. [4]
(c) State the purpose of the Control Unit (CU) within the CPU. [2]
查看答案详解收起答案详解
解题
(a) Program Counter (PC)
(b) Fetch stage role: 1. The address of the next instruction to be fetched is copied from the Program Counter (PC) into the Memory Address Register (MAR). 2. The Program Counter (PC) is incremented by 1 so that it points to the subsequent instruction in memory. 3. The MAR sends this address along the address bus to the primary memory (RAM) to locate the instruction. 4. The instruction stored at that memory location is then read and sent to the Memory Data Register (MDR) via the data bus.
(c) Control Unit (CU) purpose: 1. The CU directs and coordinates the execution of instructions within the CPU. 2. It decodes instructions to determine the required operations and sends control signals to other CPU components (like the ALU and memory).
评分标准
(a) Program Counter // PC (1)
(b) Max 4 marks: - The address of the next instruction is copied from the PC to the MAR (1) - The PC is incremented (by 1) (1) - The MAR holds the address of the instruction currently being fetched/read from memory (1) - The address in the MAR is sent to primary storage/memory using the address bus (1) - The instruction at that memory address is fetched and copied to the MDR (1)
(c) Max 2 marks: - Coordinates / manages / controls the flow of data and operations within the CPU (1) - Decodes instructions to determine what actions are required (1) - Sends control signals (via the control bus) to other components (1) - Manages the timing / clock signals of the CPU (1)
题目 11 · Short/Medium Answer
7 分
When a user enters a website URL into a web browser, several steps occur before the webpage is displayed on their screen.
(a) Describe how a Domain Name Server (DNS) is used to find the IP address of the website. [3]
(b) State the purpose of the Hypertext Transfer Protocol (HTTP/HTTPS). [2]
(c) Explain the role of the web browser once it receives the webpage data from the web server. [2]
查看答案详解收起答案详解
解题
(a) DNS Lookup: 1. The web browser sends the entered URL (domain name) to a Domain Name Server (DNS). 2. The DNS searches its database to find the IP address associated with that domain name. 3. If the DNS cannot find it, it queries other DNS servers recursively up the hierarchy. 4. Once found, the IP address is returned to the web browser to establish a connection to the correct web server.
(b) HTTP/HTTPS purpose: 1. HTTP/HTTPS defines the standardized rules and protocols for formatting and transmitting web pages over the internet. 2. HTTPS additionally encrypts the connection (using SSL/TLS) to secure data transmission and protect sensitive user information.
(c) Web browser role: 1. The browser parses and interprets the HTML, CSS, and JavaScript files received from the web server. 2. It renders these raw code files into a structured visual page containing images, text, and interactive elements for the user.
评分标准
(a) Max 3 marks: - The browser sends the URL / domain name to the DNS (1) - The DNS searches its database to find the matching IP address (1) - If the domain name is not found in the local DNS, it queries other DNS servers (1) - Once resolved, the DNS returns the IP address back to the web browser (1)
(b) Max 2 marks: - Governs/allows the transfer of webpage data / multimedia files over the internet (1) - Establishes communication rules between the client browser and the web server (1) - HTTPS provides encryption / secure data transmission using SSL/TLS protocols (1) - Prevents interception/tampering of sensitive data during transmission (1)
(c) Max 2 marks: - Interprets / parses / translates HTML (and CSS/JS) code (1) - Renders the files to display a user-friendly, interactive webpage (1) - Executes client-side script code (such as JavaScript) (1) - Manages browsing functions like history, bookmarks, and cookies (1)
Answer all questions. Use of calculators is not permitted.
11 题目 · 75 分
题目 1 · Short Answer
6 分
An algorithm is designed to process user input values and compute a tally.
``` Total <- 0 Count <- 1 INPUT Limit WHILE Count <= 5 DO INPUT Value IF Value > Limit THEN Total <- Total + (Value - Limit) ELSE Total <- Total + 1 ENDIF Count <- Count + 1 ENDWHILE OUTPUT Total ```
Complete the trace table for the following input data: `10`, `8`, `12`, `10`, `15`, `5`
查看答案详解收起答案详解
解题
Let's perform a step-by-step dry run of the algorithm with the given input data: - Initially, `Total = 0`, `Count = 1`. - First input `Limit = 10`. - First iteration (`Count = 1`): - Input `Value = 8`. - Since `8 > 10` is False, `Total <- Total + 1 = 1`. - `Count` becomes 2. - Second iteration (`Count = 2`): - Input `Value = 12`. - Since `12 > 10` is True, `Total <- Total + (12 - 10) = 1 + 2 = 3`. - `Count` becomes 3. - Third iteration (`Count = 3`): - Input `Value = 10`. - Since `10 > 10` is False, `Total <- Total + 1 = 4`. - `Count` becomes 4. - Fourth iteration (`Count = 4`): - Input `Value = 15`. - Since `15 > 10` is True, `Total <- Total + (15 - 10) = 4 + 5 = 9`. - `Count` becomes 5. - Fifth iteration (`Count = 5`): - Input `Value = 5`. - Since `5 > 10` is False, `Total <- Total + 1 = 10`. - `Count` becomes 6. - The loop terminates because `Count = 6` is not `<= 5`. - `OUTPUT Total` prints `10`.
评分标准
One mark per marking point (Max 6 marks): - 1 mark for correct initial setup (`Total = 0`, `Count = 1`, `Limit = 10`) - 1 mark for correctly tracing the first input `Value = 8` and updating `Total = 1`, `Count = 2` - 1 mark for correctly tracing the second input `Value = 12` and updating `Total = 3`, `Count = 3` - 1 mark for correctly tracing the third and fourth inputs (`Value = 10` giving `Total = 4`, `Value = 15` giving `Total = 9`) - 1 mark for correctly tracing the final input `Value = 5` and updating `Total = 10`, `Count = 6` - 1 mark for correct final output value of `10` in the output column
题目 2 · Short Answer
6 分
A database table named `Store` holds details of video games in an online library.
| Field Name | Data Type / Example Data | | :--- | :--- | | `GameID` | Text (e.g. "G101") | | `Title` | Text (e.g. "Retro Racer") | | `Price$` | Real (e.g. 14.99) | | `Downloads` | Integer (e.g. 850) | | `Multiplayer`| Boolean (e.g. TRUE) |
(a) State the most appropriate database data type for the following fields: - `Price$` - `Multiplayer`
(b) State which field should be designated as the primary key and give a reason for your choice.
(c) Write a Structured Query Language (SQL) query to display the `Title` and `Price$` of all games in the database that support multiplayer (`TRUE`) and have more than `1000` downloads.
查看答案详解收起答案详解
解题
(a) Data Types: - `Price$`: Real or Currency (as it contains decimal numbers representing monetary values). - `Multiplayer`: Boolean (as it stores true/false flags).
(b) Primary Key: - `GameID` is the most appropriate primary key. - Reason: It contains unique identifiers for each video game record, ensuring no duplicates exist.
(c) SQL Query: ```sql SELECT Title, Price$ FROM Store WHERE Multiplayer = TRUE AND Downloads > 1000; ```
评分标准
(a) 2 marks: - 1 mark for `Price$` is Real / Decimal / Currency / Single / Double (reject Integer) - 1 mark for `Multiplayer` is Boolean / Yes-No
(b) 2 marks: - 1 mark for identifying `GameID` as the primary key - 1 mark for a valid reason: uniquely identifies each record / prevents duplicates / is unique for each game
(c) 2 marks: - 1 mark for: `SELECT Title, Price$ FROM Store` - 1 mark for: `WHERE Multiplayer = TRUE AND Downloads > 1000;` (Accept `Multiplayer = Yes` or just `Multiplayer` in place of `Multiplayer = TRUE`)
题目 3 · Short Answer
6 分
Consider the logic expression:
$$Z = \text{(A AND NOT B) OR (NOT A AND C)}$$
(a) Complete the truth table for the given logic expression.
(b) Name two standard logic gates used in the logic expression.
查看答案详解收起答案详解
解题
Let's evaluate each row for the expression $Z = \text{(A AND NOT B) OR (NOT A AND C)}$: - Row 1: A=0, B=0, C=0 -> (0 AND 1) OR (1 AND 0) = 0 OR 0 = 0 - Row 2: A=0, B=0, C=1 -> (0 AND 1) OR (1 AND 1) = 0 OR 1 = 1 - Row 3: A=0, B=1, C=0 -> (0 AND 0) OR (1 AND 0) = 0 OR 0 = 0 - Row 4: A=0, B=1, C=1 -> (0 AND 0) OR (1 AND 1) = 0 OR 1 = 1 - Row 5: A=1, B=0, C=0 -> (1 AND 1) OR (0 AND 0) = 1 OR 0 = 1 - Row 6: A=1, B=0, C=1 -> (1 AND 1) OR (0 AND 1) = 1 OR 0 = 1 - Row 7: A=1, B=1, C=0 -> (1 AND 0) OR (0 AND 0) = 0 OR 0 = 0 - Row 8: A=1, B=1, C=1 -> (1 AND 0) OR (0 AND 1) = 0 OR 0 = 0
The logic gates explicitly used in the expression are: AND, OR, and NOT.
评分标准
(a) 4 marks for the Z column outputs: - 4 marks for all 8 outputs correct (0, 1, 0, 1, 1, 1, 0, 0) - 3 marks for 6 or 7 outputs correct - 2 marks for 4 or 5 outputs correct - 1 mark for 2 or 3 outputs correct - 0 marks for 0 or 1 output correct
(b) 2 marks: - 1 mark per correct gate named (Max 2): AND, OR, NOT
题目 4 · Short Answer
6 分
A programmer is writing an entry check algorithm in pseudocode for a membership portal. The user must input their age. The program must validate that the age is between 11 and 18 inclusive. If the input is invalid, it must display an error message and prompt the user to re-input until a valid age is provided.
(a) Write a pseudocode routine that implements this validation requirement.
(b) State the specific type of validation check used in (a) to verify the bounds, and suggest one other validation check that could be applied to ensure the data is entered as a positive integer number.
查看答案详解收起答案详解
解题
(a) Example Pseudocode using a post-condition loop: ``` REPEAT OUTPUT "Please enter your age (11-18 inclusive): " INPUT Age IF Age < 11 OR Age > 18 THEN OUTPUT "Error: The age is out of range. Please try again." ENDIF UNTIL Age >= 11 AND Age <= 18 ``` Alternatively, using a pre-condition loop: ``` OUTPUT "Please enter your age (11-18 inclusive): " INPUT Age WHILE Age < 11 OR Age > 18 DO OUTPUT "Error: The age is out of range. Please try again." INPUT Age ENDWHILE ```
(b) Validation Checks: - The check verifying the bounds is a **Range Check**. - Another validation check to ensure the value is a positive integer number is a **Type Check** (or a **Character/Format Check**).
评分标准
(a) 4 marks: - 1 mark for correct initialization / loop structure (e.g. REPEAT...UNTIL or WHILE...DO...ENDWHILE) - 1 mark for correct prompt and `INPUT Age` inside/before the loop - 1 mark for checking the range boundary correctly (e.g., `Age < 11 OR Age > 18` or `Age >= 11 AND Age <= 18`) - 1 mark for outputting an appropriate error message and looping correctly based on invalid entries
(b) 2 marks: - 1 mark for identifying: Range check - 1 mark for identifying: Type check (accept Character check / Format check / Presence check)
题目 5 · Short Answer
6 分
Subroutines are fundamental building blocks of structured programming.
(a) Explain two distinct differences between a function and a procedure.
(b) Explain what is meant by a local variable within a subroutine.
查看答案详解收起答案详解
解题
(a) Differences between a function and a procedure: 1. **Return value**: A function always returns a value to the main program or statement that called it, whereas a procedure performs a task but does not have to return any value. 2. **Calling context**: A function is usually called as part of an assignment expression or output statement (e.g., `Result <- CalculateArea(Width)`), whereas a procedure is called as a standalone statement (e.g., `CALL DisplayMenu()`).
(b) A local variable is a variable that is declared inside a specific subroutine (function or procedure). It only exists and can only be accessed/modified within that subroutine. It is destroyed once the subroutine finishes execution, preventing conflicts with other variables with the same name elsewhere.
评分标准
(a) 4 marks (2 marks per difference): - 1 mark for stating difference in return behavior + 1 mark for explanation/expansion (e.g., function must return a value vs procedure does not have to). - 1 mark for stating difference in how they are called + 1 mark for explanation/expansion (e.g., function as part of an expression/assignment vs procedure called as a standalone statement).
(b) 2 marks: - 1 mark for stating that it is declared/defined inside a subroutine/function/procedure. - 1 mark for explaining its scope limit: it can only be accessed within that subroutine / is destroyed when the subroutine terminates.
题目 6 · Short Answer
6 分
A one-dimensional (1D) array named `Temps` contains `30` real numbers representing daily temperature readings.
Write an algorithm in pseudocode that will: - initialize a variable to count how many days have temperatures below freezing point (less than `0`) - iterate through the entire `Temps` array - count the number of daily temperatures below `0` - output the final count with a suitable message.
查看答案详解收起答案详解
解题
Here is the pseudocode algorithm that meets the requirements: ``` FreezingCount <- 0 FOR Index <- 1 TO 30 IF Temps[Index] < 0 THEN FreezingCount <- FreezingCount + 1 ENDIF NEXT Index OUTPUT "The number of days below freezing is: ", FreezingCount ```
评分标准
6 marks available: - 1 mark for initializing count variable to 0 (e.g. `FreezingCount <- 0`) - 1 mark for correct loop structure (FOR/WHILE/REPEAT) to iterate exactly 30 times (e.g. `1 TO 30`) - 1 mark for referencing the array elements using a loop index variable (e.g. `Temps[Index]`) - 1 mark for setting the correct conditional check (e.g. `IF Temps[Index] < 0`) - 1 mark for incrementing the counter variable inside the decision block - 1 mark for outputting the final counter with an appropriate descriptive string message
题目 7 · Short Answer
6 分
A programmer needs to count the number of records stored in a text file.
(a) Write pseudocode statements to: - open the text file named "results.txt" for read access - read each line of the file until the end of the file is reached - keep a count of the number of lines read - close the file after processing.
(b) State two reasons why it is important to close a text file after a program has finished using it.
查看答案详解收起答案详解
解题
(a) Pseudocode solution: ``` LineCount <- 0 OPENFILE "results.txt" FOR READ WHILE NOT EOF("results.txt") DO READFILE "results.txt", LineData LineCount <- LineCount + 1 ENDWHILE CLOSEFILE "results.txt" ```
(b) Reasons for closing a file: - It releases lock on the file, allowing other applications or processes to access, edit, or delete it. - It flushes any buffered data to ensure it is written to disk, preventing data loss or file corruption. - It frees up system resources (such as memory or file handles) allocated to tracking that open file.
评分标准
(a) 4 marks: - 1 mark for opening "results.txt" for read access (e.g., `OPENFILE ... FOR READ`) - 1 mark for a correct loop that reads until the end of file (e.g., `WHILE NOT EOF("results.txt")`) - 1 mark for reading line data and updating count (e.g., `READFILE` and `LineCount <- LineCount + 1`) - 1 mark for closing the file properly (e.g., `CLOSEFILE "results.txt"`)
(b) 2 marks: - 1 mark for each valid reason (Max 2), e.g.: - To release system memory/resources/file handles - To prevent file corruption/ensure data is safely written - To allow other users/applications to access/lock the file
题目 8 · Short Answer
6 分
Programmers must identify and fix errors during the development of software.
(a) Explain what is meant by the following terms, and give one example of each: - Syntax error - Logic error
(b) Identify two features of an Integrated Development Environment (IDE) that are designed to help a programmer find or debug errors.
查看答案详解收起答案详解
解题
(a) Error definitions and examples: - **Syntax error**: An error that occurs when code violates the grammatical rules of the programming language. The translator cannot compile or interpret the program. - *Example*: A missing closing bracket `)` or misspelling a keyword like `WHLIE` instead of `WHILE`. - **Logic error**: An error that occurs when the program runs successfully without crashing, but produces incorrect or unexpected output because the algorithm design is flawed. - *Example*: Using addition `+` instead of subtraction `-` or setting a loop boundary to `< 10` instead of `<= 10`.
(b) IDE debugging/error-finding features (Any two from): - **Syntax highlighting / color coding**: Highlights language elements to reveal unmatched brackets or misspelled keywords. - **Breakpoints**: Allows the programmer to pause execution at a specific line to inspect variables. - **Single-stepping**: Executes code line-by-line to monitor states sequentially. - **Watch window**: Tracks changes in variables dynamically as code runs. - **Auto-completion / Intellisense**: Suggests syntax, parameters, and variable names as you type.
评分标准
(a) 4 marks: - 1 mark for definition of Syntax error (rules of language broken / program won't compile) - 1 mark for a valid Syntax error example - 1 mark for definition of Logic error (program runs but produces incorrect result) - 1 mark for a valid Logic error example
(b) 2 marks: - 1 mark for each valid IDE debugging feature (Max 2), e.g.: - Breakpoints - Single-stepping - Watch window / variable tracker - Syntax highlighting / error underling in real-time
题目 9 · Logic Gates
6 分
A safety system in a manufacturing plant monitors three conditions: - Guard door closed (\(D = 1\)) - Emergency stop pressed (\(E = 1\)) - Temperature high (\(T = 1\))
The system triggers a warning light (\(W = 1\)) if: The emergency stop is pressed (\(E = 1\)) OR The guard door is not closed (\(D = 0\)) AND the temperature is high (\(T = 1\))
(a) Write the logic expression for this system, using the variables \(D, E, T\) and output \(W\). [3]
(b) State the logic gate that is equivalent to the expression: \( \text{NOT (A AND B)} \). [1]
(c) Explain why the NAND gate is often referred to as a 'universal gate'. [2]
查看答案详解收起答案详解
解题
(a) The first part 'The emergency stop is pressed' is represented by \(E\). The second part 'The guard door is not closed AND the temperature is high' is represented by \(\text{NOT } D \text{ AND } T\). These are combined with OR: \(W = E \text{ OR } (\text{NOT } D \text{ AND } T)\). (b) \(\text{NOT (A AND B)}\) represents the NAND operation. (c) NAND gates are universal because combinations of them can construct any basic logic function (AND, OR, NOT, NOR, etc.).
评分标准
(a) [3 marks] - 1 mark for correct use of NOT with D - 1 mark for correct AND of (NOT D) and T - 1 mark for correct OR of E with the rest of the expression (b) [1 mark] - 1 mark for NAND (c) [2 marks] - 1 mark for explaining that combinations of NAND gates can replicate any other logic gate - 1 mark for explaining that this simplifies manufacturing / reduces chip production costs
题目 10 · Databases
6 分
A database table, `Books`, stores information about the inventory of a school library: - `BookID` (e.g. B101, B102) - `Title` (e.g. Macbeth, Hamlet) - `Author` (e.g. Shakespeare) - `Available` (e.g. True, False) - `Pages` (e.g. 120, 240)
(a) State the most appropriate data type for the following fields: [2] - `Available` - `Pages`
(b) Write a Structured Query Language (SQL) query to display the `Title` and `Author` of all books that have more than 200 pages and are currently available. [4]
查看答案详解收起答案详解
解题
(a) `Available` represents a binary yes/no state, so 'Boolean' is the correct data type. `Pages` represents whole numbers, so 'Integer' is correct. (b) To retrieve fields `Title` and `Author`, use `SELECT Title, Author`. To query from the table `Books`, use `FROM Books`. To filter for books with pages greater than 200 and available, use `WHERE Pages > 200 AND Available = True`.
评分标准
(a) [2 marks] - 1 mark for Boolean (accept Logical) - 1 mark for Integer (accept Number / Numeric / Real is incorrect) (b) [4 marks] - 1 mark: SELECT Title, Author - 1 mark: FROM Books - 1 mark: WHERE Pages > 200 - 1 mark: AND Available = True (accept TRUE / Yes)
题目 11 · Scenario Programming
15 分
A 2D array, named `Inventory[]`, is designed to keep track of store item details. The array holds a maximum of 80 products. Both columns store data as strings: • Column 1 stores the unique product code (e.g., "P104") • Column 2 stores the current stock level (e.g., "45")
The variable `CurrentSize` contains the integer count of products currently saved in the array.
Create a program that meets the following requirements: • Present a menu containing three options to the user: - add new inventory items - search for an item and change its stock level - find and display all low stock items (stock count below 10) • Validate the menu selection input. • Permit a user to add a maximum of 4 new items during a single menu action. • Ensure the total product count inside the array does not exceed 80. • Following any additions, sort the array by the product code in alphabetical order, provided that the array contains two or more records. • Allow the user to search for a product code; if it exists, prompt for a new stock count and update the array. • Iterate through the array and output the product codes and stock levels of all products whose stock is less than 10.
Write your solution in program code or pseudocode, including explanatory comments. There is no need to write declarations for variables, arrays, or constants, as you can assume they are pre-declared. All inputs and outputs must feature user-friendly messages.
You do not need to initialise the array `Inventory[]` or the variable `CurrentSize`.
查看答案详解收起答案详解
解题
// Example 15-mark answer in pseudocode
Cont <- TRUE WHILE Cont = TRUE DO // Display menu options OUTPUT "Please select an option:" OUTPUT "1. Add new products" OUTPUT "2. Search and update stock" OUTPUT "3. Display low stock items" OUTPUT "4. Exit program" INPUT Choice
// Validate the menu choice WHILE Choice < 1 OR Choice > 4 DO OUTPUT "Invalid input. Please enter 1, 2, 3, or 4:" INPUT Choice ENDWHILE
IF Choice = 1 THEN // Check if array is already full IF CurrentSize = 80 THEN OUTPUT "The inventory is full. Cannot add more items." ELSE OUTPUT "How many products would you like to add (1 to 4)?" INPUT NewItems // Validate number of items to add WHILE NewItems < 1 OR NewItems > 4 DO OUTPUT "Error: You can only add between 1 and 4 products. Enter again:" INPUT NewItems ENDWHILE
// Ensure the addition does not exceed the limit of 80 WHILE CurrentSize + NewItems > 80 DO OUTPUT "Error: Only ", 80 - CurrentSize, " spaces left. Re-enter:" INPUT NewItems ENDWHILE
// Input new product details FOR Count <- CurrentSize + 1 TO CurrentSize + NewItems OUTPUT "Enter product code (e.g., P104):" INPUT Inventory[Count, 1] OUTPUT "Enter initial stock level:" INPUT Inventory[Count, 2] NEXT Count CurrentSize <- CurrentSize + NewItems
// Sort array alphabetically by product code using a bubble sort if size >= 2 IF CurrentSize >= 2 THEN REPEAT SwapFlag <- FALSE FOR Count <- 1 TO CurrentSize - 1 IF Inventory[Count + 1, 1] < Inventory[Count, 1] THEN SwapFlag <- TRUE TempCode <- Inventory[Count, 1] TempStock <- Inventory[Count, 2]
Inventory[Count + 1, 1] <- TempCode Inventory[Count + 1, 2] <- TempStock ENDIF NEXT Count UNTIL SwapFlag = FALSE ENDIF OUTPUT "Products successfully added and sorted." ENDIF
ELSEIF Choice = 2 THEN // Search and update stock level OUTPUT "Enter product code to search:" INPUT TargetCode Found <- FALSE Index <- 0
FOR Count <- 1 TO CurrentSize IF Inventory[Count, 1] = TargetCode THEN Found <- TRUE Index <- Count ENDIF NEXT Count
IF Found = TRUE THEN OUTPUT "Product found. Current stock level is: ", Inventory[Index, 2] OUTPUT "Enter new stock level:" INPUT NewStock Inventory[Index, 2] <- NewStock OUTPUT "Stock level updated successfully." ELSE OUTPUT "Product code not found." ENDIF
ELSEIF Choice = 3 THEN // Find and display items with stock less than 10 LowStockFound <- FALSE OUTPUT "Low Stock Alert (Stock < 10):" FOR Count <- 1 TO CurrentSize // Converting string to integer for comparison IF STRING_TO_NUM(Inventory[Count, 2]) < 10 THEN OUTPUT "Code: ", Inventory[Count, 1], " | Stock: ", Inventory[Count, 2] LowStockFound <- TRUE ENDIF NEXT Count
IF LowStockFound = FALSE THEN OUTPUT "All products currently have sufficient stock levels." ENDIF
ELSEIF Choice = 4 THEN // Set control variable to terminate the loop Cont <- FALSE OUTPUT "Exiting program." ENDIF ENDWHILE
评分标准
AO2: Apply knowledge and understanding of the principles and concepts of computer science to a given context, including the analysis and design of computational or programming problems (Max 9 marks)
Band 1: 1–3 marks - At least one programming technique has been used (e.g. simple selection for choice or basic input/output loop). - Variables or data structures are named but may not be used correctly.
Band 2: 4–6 marks - Multiple relevant programming techniques are used appropriately (e.g. loop for search, validation checks, sorting routine). - Data structures are used correctly to store some of the required parameters.
Band 3: 7–9 marks - A wide range of appropriate programming techniques are correctly implemented. - All criteria stated in the scenario are fully covered (validated menu, limit checks of adding up to 4 items and total limit of 80, bubble sort alphabetically, linear search with matching indices, and threshold-based output). - 2D array structures are manipulated accurately.
AO3: Provide solutions to problems by evaluating computer systems, making reasoned judgements, and presenting conclusions (Max 6 marks)
Band 1: 1–2 marks - Solution is illogical or inaccurate in multiple places. - Few or no comments are present. - Identifiers are vague.
Band 2: 3–4 marks - Solution is in a logical order but contains minor errors. - Some comments are included. - Most identifiers are meaningfully named.
Band 3: 5–6 marks - The program is fully commented and logically structured. - Identifiers are highly descriptive and meaningful to their roles. - The solution accurately performs all tasks specified in the scenario.
想知道自己有几分把握?
thinka 是 DSE 学生在用的 AI 练习应用,提供无限量练习题、即时自动批改和详细解题步骤。超过 100,000 名学生用它确认自己是真的会,而不只是「以为会」。