An original Thinka practice paper modelled on the structure and difficulty of the Jun 2026 (V3) Cambridge IGCSE Computer Science (0478) paper. Not affiliated with or reproduced from Cambridge.
卷一: Computer Systems
Answer all questions. Calculators must not be used. Write answers clearly in black or dark blue pen.
26 题目 · 62.599999999999994 分
题目 1 · multiple_choice
1 分
Which register in the Central Processing Unit (CPU) holds the address of the next instruction to be fetched from memory?
A.Accumulator (ACC)
B.Current Instruction Register (CIR)
C.Memory Data Register (MDR)
D.Program Counter (PC)
查看答案详解收起答案详解
解题
The Program Counter (PC) holds the memory address of the next instruction to be fetched from primary storage (RAM) during the fetch–decode–execute cycle. Once the address is copied to the Memory Address Register (MAR), the PC is incremented to point to the subsequent instruction.
评分标准
Award 1 mark for D (Program Counter (PC)). All other options score 0.
题目 2 · Short Answer & Recall
1.7 分
State what is meant by an overflow error when performing binary addition in an 8-bit register.
查看答案详解收起答案详解
解题
An 8-bit register can store values from 0 to 255 (or 2^8 - 1). When the sum of two numbers exceeds 255 (or produces a 9th carry bit), the extra most significant bit is lost or cannot be accommodated by the 8-bit register, resulting in an overflow error.
评分标准
Award 1 mark for identifying that the calculation exceeds register capacity / result is greater than 255; award 1 mark for stating that the 9th bit / carry bit cannot be stored or causes an incorrect result (scaled to 1.7 marks).
题目 3 · Short Answer & Recall
1.7 分
Explain one difference between the ASCII character set and the Unicode character set.
查看答案详解收起答案详解
解题
ASCII uses standard 7 or 8 bits per character, limiting it to 128 or 256 unique characters (primarily English alphabet and basic punctuation). Unicode uses 16 or 32 bits per character, enabling representation of millions of characters across diverse world languages, scripts, and emojis.
评分标准
Award 1 mark for comparing bit length / storage per character (e.g. Unicode uses 16/32 bits whereas ASCII uses 7/8 bits); award 1 mark for explaining that Unicode can represent more symbols/languages/characters worldwide (scaled to 1.7 marks).
题目 4 · Short Answer & Recall
1.7 分
Identify two items of data that are contained in the header of a data packet.
查看答案详解收起答案详解
解题
A standard packet header contains essential metadata required for routing and reassembly, including the destination IP address, sender (originator) IP address, and the packet sequence/order number.
评分标准
Award 1 mark for each valid item from: Destination IP address, Sender/Originator IP address, Packet sequence number / packet ID, Packet length / size (to a maximum of 2 points, scaled to 1.7 marks).
题目 5 · Short Answer & Recall
1.7 分
Describe the function of a timeout in an Automatic Repeat reQuest (ARQ) error-detection protocol.
查看答案详解收起答案详解
解题
In ARQ, after transmitting a packet, the sender starts a countdown timer. If the recipient does not return a positive acknowledgement before the timeout period finishes (due to packet loss or corruption), the sender assumes the transmission failed and sends the packet again.
评分标准
Award 1 mark for stating that the timeout is the predetermined waiting time for an acknowledgement; award 1 mark for stating that data is automatically resent if the timer expires before receipt of an ACK (scaled to 1.7 marks).
题目 6 · Short Answer & Recall
1.7 分
State the role of the Program Counter (PC) during the fetch stage of the fetch-decode-execute cycle.
查看答案详解收起答案详解
解题
During the fetch stage, the address in the Program Counter is copied to the MAR. The Program Counter is then incremented by one so that it points to the subsequent instruction in memory.
评分标准
Award 1 mark for holding the address of the next instruction to be fetched; award 1 mark for stating it is incremented / updated to point to the next instruction in sequence (scaled to 1.7 marks).
题目 7 · Short Answer & Recall
1.7 分
Outline what happens within the central processing unit (CPU) when a hardware interrupt is generated.
查看答案详解收起答案详解
解题
Upon receiving an interrupt signal, the CPU checks its priority. If accepted, it halts the current instruction sequence, stores the state and registers in memory, and jumps to the relevant Interrupt Service Routine (ISR). Once the ISR completes, the CPU restores the previous state and resumes the original task.
评分标准
Award 1 mark for stating current execution is suspended and registers/state are saved; award 1 mark for stating the CPU runs the Interrupt Service Routine (ISR) / interrupt handler (scaled to 1.7 marks).
题目 8 · Short Answer & Recall
1.7 分
State the difference between a session cookie and a persistent cookie.
查看答案详解收起答案详解
解题
Session cookies exist only during the active browsing session and are erased when the user terminates the browser session. Persistent cookies are written to the client hard disk/storage and remain active across multiple sessions until their predefined expiration date passes or they are deleted.
评分标准
Award 1 mark for session cookie deleted when browser is closed / temporary; award 1 mark for persistent cookie stored on hard disk / retained across sessions until expiry (scaled to 1.7 marks).
题目 9 · Short Answer & Recall
1.7 分
Identify two key components that make up an expert system in artificial intelligence.
查看答案详解收起答案详解
解题
An expert system is composed of a knowledge base (repository of facts and data), a rule base (set of IF-THEN rules), an inference engine (the reasoning mechanism that applies rules to data), and a user interface.
评分标准
Award 1 mark for each valid component from: Knowledge base, Inference engine, Rule base, User interface / explanation facility (to a maximum of 2 points, scaled to 1.7 marks).
题目 10 · short_answer
2 分
Describe the role of the Program Counter (PC) during the fetch stage of the fetch-decode-execute cycle.
查看答案详解收起答案详解
解题
1. The Program Counter stores the address of the next instruction to be fetched from main memory. 2. The address is transferred to the Memory Address Register (MAR). 3. The Program Counter is then incremented by 1 so that it points to the subsequent instruction in sequence.
评分标准
Award 1 mark for each valid point up to a maximum of 2 marks: - Holds / stores the memory address of the next instruction to be fetched [1] - Increments (by 1) after the address is copied to MAR [1]
题目 11 · short_answer
2 分
State two events that will cause a sender to retransmit a data packet when using an Automatic Repeat reQuest (ARQ) protocol.
查看答案详解收起答案详解
解题
ARQ uses acknowledgements and timeouts. Retransmission is triggered if: 1. The receiver detects corrupted data and sends back a negative acknowledgement (NACK). 2. The packet (or acknowledgement) is lost in transit, causing the sender's timer to expire (timeout) before receiving any acknowledgement.
评分标准
Award 1 mark for each valid point (max 2 marks): - Receiving a negative acknowledgement / NACK [1] - A timeout occurs / time limit expires before receiving an acknowledgement [1]
题目 12 · short_answer
2 分
Convert the denary number \(-43\) into an 8-bit two's complement binary integer. Show your working.
Step 2: Invert all bits (one's complement): \(00101011 \rightarrow 11010100\)
Step 3: Add 1 to the result (two's complement): \(11010100 + 1 = 11010101_2\)
Alternative check using place values: \(-128 + 64 + 16 + 4 + 1 = -128 + 85 = -43\).
评分标准
Award 1 mark for correct working (e.g. converting 43 to 00101011 and showing inversion / addition of 1, or correct place-value evaluation) [1] Award 1 mark for the correct final 8-bit binary representation: 11010101 [1]
题目 13 · short_answer
2 分
State two reasons why a hardware device or running program would generate an interrupt signal to the CPU.
查看答案详解收起答案详解
解题
Interrupts are signals sent from a device or program to the CPU to request immediate attention. Common causes include: - Hardware I/O completion (e.g. data transfer finished from storage) - Hardware faults/warnings (e.g. out of paper, power fluctuation) - Software execution errors (e.g. illegal operation, arithmetic overflow, divide by zero) - User input events (e.g. key press or mouse click)
评分标准
Award 1 mark for each valid reason up to a maximum of 2 marks: - Hardware error / device fault (e.g. paper jam, disk read failure) [1] - I/O operation completion / data ready to be processed [1] - Software exception / runtime error (e.g. division by zero, null pointer) [1] - User interaction / hardware input event (e.g. key pressed, mouse movement) [1]
题目 14 · short_answer
2 分
Explain how pharming redirects a user to a fraudulent website without the user clicking a malicious link.
查看答案详解收起答案详解
解题
Pharming is a cyber attack that modifies DNS resolution tables or local host files. When a victim types a legitimate URL into their browser, the altered DNS table translates the valid domain name into the attacker's server IP address, seamlessly redirecting the user to a bogus website designed to capture login details.
评分标准
Award 1 mark for the mechanism and 1 mark for the effect/outcome: - Malicious code alters DNS server records / local host file [1] - When user enters a legitimate URL/domain name, they are redirected to a fraudulent/fake IP address [1]
题目 15 · short_answer
2 分
An expert system is a form of artificial intelligence. Identify two internal components of an expert system, excluding the user interface.
查看答案详解收起答案详解
解题
An expert system consists of four primary components: 1. User Interface (allows interaction) 2. Knowledge Base (stores factual information and domain data) 3. Rule Base (contains IF-THEN rules and logic relationships) 4. Inference Engine (applies rules to the knowledge base to deduce solutions and make decisions)
评分标准
Award 1 mark for each valid component up to a maximum of 2 marks: - Knowledge base [1] - Inference engine [1] - Rule base [1] (Do NOT accept User Interface as it is excluded in the question)
题目 16 · Structured Explanation
4 分
A user enters a website URL into their browser.
Explain how the Domain Name System (DNS) is used to locate and retrieve the requested webpage.
查看答案详解收起答案详解
解题
1. The web browser sends the domain name (requested by the user) to a DNS server (resolver/lookup). 2. The DNS server looks up its database of domain names and matching IP addresses. 3. The DNS server returns the specific IP address back to the user's web browser (or forwards the query to other DNS servers if not found). 4. The browser then uses this resolved IP address to establish communication and request the webpage directly from the target web server hosting the files.
评分标准
Award 1 mark for each valid step explained, up to a maximum of 4 marks: - Browser sends the domain name/URL to a DNS server [1] - DNS server searches / queries its database / records for matching IP address [1] - If not found locally, the request is passed/forwarded to higher-level/other DNS servers [1] - DNS server returns the IP address to the browser [1] - Browser uses the IP address to send a request (via HTTP/HTTPS) to the web server [1]
题目 17 · Structured Explanation
4 分
During program execution, an interrupt signal is sent to the Central Processing Unit (CPU).
Explain how the operating system handles this interrupt.
查看答案详解收起答案详解
解题
1. The CPU finishes executing the current instruction in the fetch-decode-execute cycle. 2. The current state and register contents (such as Program Counter and accumulator) are saved onto a stack or temporary memory area. 3. The operating system checks the priority/source of the interrupt and loads the relevant Interrupt Service Routine (ISR) / interrupt handler. 4. Once the ISR has finished execution, the saved register values and program state are restored, allowing the original task to resume seamlessly.
评分标准
Award 1 mark per valid point up to a maximum of 4 marks: - CPU completes the current execution cycle / instruction [1] - The current contents of the registers / program state / Program Counter are saved (to a stack / memory) [1] - The operating system / CPU determines the source / priority of the interrupt [1] - The corresponding Interrupt Service Routine (ISR) / interrupt handler is loaded/executed [1] - After the ISR finishes, the saved register values/state are restored [1] - The previous process / original task resumes execution [1]
题目 18 · Structured Explanation
4 分
A company uses asymmetric encryption to securely receive confidential files from clients over the internet.
Explain how asymmetric encryption ensures the confidentiality of these files during transmission.
查看答案详解收起答案详解
解题
1. Asymmetric encryption uses a pair of mathematically linked but non-identical keys: a public key and a private key. 2. The receiving company distributes its public key openly to any client wishing to send files, while strictly keeping its corresponding private key confidential. 3. The client encrypts the plaintext data using the recipient's public key before sending it across the network. 4. Once encrypted, the ciphertext can only be decrypted using the corresponding private key held solely by the company, ensuring unauthorized interceptors cannot decrypt or read the file.
评分标准
Award 1 mark for each valid explanation point up to a maximum of 4 marks: - Uses a pair of mathematically linked keys / a public key and a private key [1] - Public key is made available to everyone/the sender; private key is kept secret/confidential by the recipient [1] - Sender/client encrypts the file/data using the recipient's public key [1] - Only the recipient can decrypt the file using their corresponding private key [1] - Data cannot be decrypted with the public key / unauthorized parties cannot read the ciphertext [1]
题目 19 · Structured Explanation
4 分
A modern computer system uses Solid State Drives (SSDs) rather than Hard Disk Drives (HDDs) for secondary storage.
Explain how an SSD stores data and why this makes it more durable than an HDD.
查看答案详解收起答案详解
解题
1. Storage mechanism: An SSD stores data in non-volatile flash memory using millions of microscopic transistors configured with floating gates and control gates. 2. The presence or absence of trapped electrical charge (electrons) in the floating gate alters the threshold voltage, representing binary bits (0s and 1s). 3. Durability aspect: Unlike an HDD, which relies on physical spinning magnetic platters and moving mechanical read/write actuator arms, an SSD has zero moving mechanical parts. 4. Consequently, SSDs are much more resistant to mechanical failure, physical shock, and drops (eliminating the risk of a head crash).
评分标准
Award 1 mark per valid point up to a maximum of 4 marks (maximum 2 marks for operation, maximum 2 marks for durability):
Operation: - Uses flash / non-volatile NAND memory [1] - Uses floating gate / control gate transistors [1] - Traps / controls electrical charge (electrons) to represent binary states / 0s and 1s [1]
Durability: - SSD has no moving / mechanical parts [1] - HDD has moving read/write heads / spinning magnetic platters [1] - SSD is not vulnerable to head crashes / physical shock / dropping / vibration [1]
题目 20 · Structured Explanation
4 分
An automated temperature control system is installed in a commercial greenhouse.
Explain how sensors, a microprocessor, and actuators work together to maintain the temperature at a preset level.
查看答案详解收起答案详解
解题
1. Temperature sensors continuously monitor the ambient conditions in the greenhouse and send analog data, which is converted to digital data (via an ADC) for processing. 2. The microprocessor receives the digitized data and compares it against preset target temperature thresholds stored in memory. 3. If the reading is outside the acceptable range (e.g. too cold), the microprocessor generates an output control signal sent to an actuator (e.g., activating a heating unit). 4. If the reading is too high, the microprocessor activates actuators to open motorised roof vents or run cooling fans; the entire monitoring-comparison-action cycle repeats continuously.
评分标准
Award 1 mark per valid point up to a maximum of 4 marks: - Temperature sensor measures/records the environmental temperature continuously [1] - Sensor sends data to the microprocessor (ADC converts analogue sensor data to digital) [1] - Microprocessor compares received reading with preset / stored threshold value(s) [1] - If temperature is below threshold, microprocessor signals an actuator to turn on heating [1] - If temperature is above threshold, microprocessor signals an actuator to open vents / turn on cooling fans [1] - The process repeats continuously / in a loop [1]
题目 21 · Structured Explanation
4 分
A digital audio track is recorded using sound sampling.
Explain how sample rate and sample resolution affect both the quality of the recorded sound and the resulting file size.
查看答案详解收起答案详解
解题
1. Sample rate refers to how many audio samples are captured per second (measured in Hz/kHz). A higher sample rate samples the analogue wave more frequently, reproducing the original analogue waveform more accurately and resulting in higher sound quality. 2. Sample resolution (bit depth) refers to the number of bits allocated per sample. A higher sample resolution provides more discrete amplitude levels, resulting in closer approximation of volume levels and higher fidelity. 3. File size is directly proportional to both parameters (File size = sample rate × sample resolution × duration × number of channels). 4. Increasing either sample rate or sample resolution causes more data bits to be stored per unit of time, which increases the total file size.
评分标准
Award 1 mark per valid point up to a maximum of 4 marks: - Sample rate: increasing sample rate captures more samples per second / closer approximation to original wave / improves quality [1] - Sample resolution: increasing sample resolution allocates more bits per sample / gives finer amplitude levels / reduces quantization error / improves quality [1] - Increasing sample rate increases the total number of samples stored, thus increasing file size [1] - Increasing sample resolution increases bits stored per sample, thus increasing file size [1] - Stating the relationship: higher quality / fidelity leads to larger file size (or vice versa) [1]
题目 22 · Cloze Paragraph Completion
5 分
Complete the paragraph describing the fetch stage of the Fetch–Decode–Execute (FDE) cycle by choosing the correct terms from the list.
Not all terms will be used.
• Accumulator (ACC) • Address bus • Arithmetic Logic Unit (ALU) • Control bus • Current Instruction Register (CIR) • Data bus • Memory Address Register (MAR) • Memory Data Register (MDR) • Program Counter (PC)
At the start of the cycle, the address of the next instruction is copied from the (1) .................................................... to the (2) .................................................... .
This memory address is transmitted to primary memory using the (3) .................................................... .
The instruction stored at this location is transferred into the (4) .................................................... along the data bus.
Finally, the instruction is copied from there into the (5) .................................................... where it is held ready to be decoded.
查看答案详解收起答案详解
解题
1. Program Counter (PC) holds the memory address of the next instruction to be fetched. 2. Memory Address Register (MAR) receives the address from the PC. 3. Address bus carries the memory address from the MAR to primary storage (RAM). 4. Memory Data Register (MDR) temporarily stores the instruction fetched from RAM. 5. Current Instruction Register (CIR) holds the fetched instruction ready for the Control Unit to decode.
评分标准
1 mark for each correct term placed in the corresponding gap: • (1) Program Counter / PC [1] • (2) Memory Address Register / MAR [1] • (3) Address bus [1] • (4) Memory Data Register / MDR [1] • (5) Current Instruction Register / CIR [1]
题目 23 · short_answer
1.75 分
Convert the denary integer \(-77\) into an 8-bit two's complement binary integer. Show your working.
查看答案详解收起答案详解
解题
Method 1 (Invert and add 1): 1. Convert positive \(+77\) to 8-bit binary: \(64 + 8 + 4 + 1 = 01001101\). 2. Invert all bits (one's complement): \(10110010\). 3. Add 1 to get two's complement: \(10110010 + 1 = 10110011\).
1 mark for correct method shown (e.g. converting \(+77\) to \(01001101\) and inverting/adding 1, or correct place value addition). 0.75 marks for the correct final 8-bit binary value: 10110011.
题目 24 · short_answer
1.75 分
Convert the 8-bit two's complement binary integer \(11010110\) into its denary value. Show your working.
1 mark for showing valid working (e.g. \(-128 + 64 + 16 + 4 + 2\) or inverting and adding 1 to get \(+42\)). 0.75 marks for the correct final denary answer: -42.
题目 25 · short_answer
1.75 分
Convert the denary integer \(-105\) into an 8-bit two's complement binary integer. Show your working.
查看答案详解收起答案详解
解题
Method 1 (Invert and add 1): 1. Convert positive \(+105\) to 8-bit binary: \(64 + 32 + 8 + 1 = 01101001\). 2. Invert all bits (one's complement): \(10010110\). 3. Add 1 to the result: \(10010110 + 1 = 10010111\).
1 mark for correct method shown (e.g. converting \(+105\) to \(01101001\) and inverting bits, or using \(-128\) base weight). 0.75 marks for the correct final 8-bit binary value: 10010111.
题目 26 · short_answer
1.75 分
Convert the 8-bit two's complement binary integer \(10101100\) into its denary value. Show your working.
查看答案详解收起答案详解
解题
Method 1 (Direct place value calculation): Place value weights: \(-128, 64, 32, 16, 8, 4, 2, 1\) Bits: \(1, 0, 1, 0, 1, 1, 0, 0\) Calculation: \(-128 + 32 + 8 + 4 = -128 + 44 = -84\).
1 mark for showing correct working (e.g. \(-128 + 32 + 8 + 4\) or inverting and adding 1 to find \(84\)). 0.75 marks for the correct final denary answer: -84.
Answer all questions. Calculators must not be used. Write pseudocode following standard syllabus conventions.
18 题目 · 68 分
题目 1 · 選擇題
1 分
Consider the following pseudocode segment:
```text DECLARE Subject : STRING DECLARE Result : STRING
Subject <- "CHEMISTRY" Result <- SUBSTRING(Subject, 3, 4) ```
Identify the string stored in the variable `Result` after execution.
A."EMIS"
B."HEMI"
C."EMIST"
D."MIST"
查看答案详解收起答案详解
解题
In Cambridge IGCSE pseudocode, string indexing begins at position 1. The function `SUBSTRING(string, start, length)` extracts a substring beginning at character index `start` for a total of `length` characters.
In the string `"CHEMISTRY"`: - Index 1: `C` - Index 2: `H` - Index 3: `E` - Index 4: `M` - Index 5: `I` - Index 6: `S` - Index 7: `T` - Index 8: `R` - Index 9: `Y`
Starting at index 3 with a length of 4 characters extracts indices 3, 4, 5, and 6, which gives `"EMIS"`.
评分标准
1 mark for A ("EMIS"). Accept only A.
题目 2 · 選擇題
1 分
A database table named `PRODUCT` stores details of items in a warehouse. It contains the fields `ProductCode`, `Description`, `Category`, and `UnitPrice`.
Identify the SQL statement that displays only the description and unit price of all products in the 'Electronics' category, ordered from highest price to lowest price.
A.SELECT Description, UnitPrice FROM PRODUCT WHERE Category = 'Electronics' ORDER BY UnitPrice DESCENDING;
B.SELECT Description, UnitPrice FROM PRODUCT WHERE Category = 'Electronics' ORDER BY UnitPrice ASCENDING;
C.SELECT ProductCode, Description, UnitPrice FROM PRODUCT WHERE Category = 'Electronics' ORDER BY UnitPrice DESCENDING;
D.SELECT * FROM PRODUCT WHERE Category = 'Electronics' ORDER BY UnitPrice DESCENDING;
查看答案详解收起答案详解
解题
To select only the description and unit price, the `SELECT` clause must specify `Description, UnitPrice`. The table is specified by `FROM PRODUCT`. The condition to filter for the category 'Electronics' is `WHERE Category = 'Electronics'`. To order results from highest price to lowest price (descending order), the clause is `ORDER BY UnitPrice DESCENDING`.
Therefore, the correct SQL query is: `SELECT Description, UnitPrice FROM PRODUCT WHERE Category = 'Electronics' ORDER BY UnitPrice DESCENDING;`
评分标准
1 mark for A. Accept only A.
题目 3 · short-answer
4 分
Identify the most suitable pseudocode data type for each of the following pieces of data:
(a) The number of students registered for an exam (e.g. 28) (b) The mass of a package in kilograms (e.g. 12.45) (c) A single character indicating an exam grade (e.g. 'A') (d) Whether a library book is currently on loan (e.g. FALSE)
查看答案详解收起答案详解
解题
(a) The count of students is a whole number with no fractional part, so INTEGER is required. (b) The mass contains a fractional/decimal component, so REAL is required. (c) A single character enclosed in quotes is represented by CHAR. (d) A flag indicating one of two states (TRUE or FALSE) is represented by BOOLEAN.
评分标准
1 mark for each correct data type: (a) INTEGER (b) REAL (c) CHAR (accept CHARACTER) (d) BOOLEAN
题目 4 · short-answer
2 分
Explain the difference between validation and verification when entering data into a computer program.
查看答案详解收起答案详解
解题
Validation checks if input data follows set criteria (e.g. range, type, length, presence) automatically by the system. Verification checks that data input is identical to the source document, performed either by double data entry or visual checking.
评分标准
1 mark for a correct explanation of validation: - Automated check / check by software to ensure data is acceptable / sensible / within rules / valid format.
1 mark for a correct explanation of verification: - Check that data matches the original source / is entered correctly without transcription errors (e.g., via visual check or double entry).
Note: Reject answers stating validation checks that data is 'correct' or 'true'.
题目 5 · short-answer
2 分
State the purpose of a primary key in a database table and give one reason why a person's surname is not suitable to be used as a primary key.
查看答案详解收起答案详解
解题
A primary key ensures every record has a unique identifier so that specific rows can be referenced and retrieved unambiguously. Surnames cannot serve this purpose because two or more distinct individuals may share the exact same surname, violating the uniqueness constraint.
评分标准
1 mark for stating the purpose: - Uniquely identifies each record / row / entity in a table.
1 mark for the reason: - Surnames are not unique / duplicates can exist / different people can share the same surname.
题目 6 · short-answer
2 分
Compare the use of a count-controlled loop (FOR ... NEXT) and a pre-condition loop (WHILE ... ENDWHILE) by stating when it is appropriate to use each type.
查看答案详解收起答案详解
解题
A FOR loop is predetermined (fixed iterations), whereas a WHILE loop is condition-controlled and checks the condition at the start, meaning it will not execute at all if the initial condition is false.
评分标准
1 mark for FOR loop: - When the number of iterations / repetitions is known / fixed in advance.
1 mark for WHILE loop: - When the number of iterations is unknown / depends on a condition (being met) / when the loop body might need to execute zero times.
题目 7 · short-answer
2 分
A programmer uses standard pseudocode file handling commands.
(a) State what happens to any existing data in a text file when it is opened in WRITE mode. (b) State why a file must be closed after writing to it is completed.
查看答案详解收起答案详解
解题
(a) Opening a file in WRITE mode truncates the file, clearing any previous contents. (b) Closing a file flushes write buffers to disk, prevents file locking or corruption, and releases operating system resources.
评分标准
(a) 1 mark for: - Existing data is deleted / overwritten / wiped / lost / a new empty file is created.
(b) 1 mark for any one of: - To save / write all buffered data to storage / disk. - To release system memory / file handle / allow other processes to access the file. - To prevent data loss / corruption.
题目 8 · short-answer
3 分
The string variable `CourseCode` is assigned the value `"CS2026P2"`.
State the result returned by each of the following pseudocode operations:
(a) The total number of characters in "CS2026P2" is 8. (b) SUBSTRING starting at index 3 with length 4 extracts characters at positions 3, 4, 5, and 6: "2026". (c) SUBSTRING at index 1 with length 2 extracts "CS", and LCASE converts it to lowercase: "cs".
评分标准
1 mark for each correct result: (a) 8 (b) "2026" (accept 2026) (c) "cs" (quotes optional, must be lowercase)
题目 9 · Trace Table & Algorithm Analysis
3.5 分
Consider the following pseudocode algorithm:
```text DECLARE Num, Rem, Count : INTEGER Count <- 0 INPUT Num WHILE Num > 0 DO Rem <- MOD(Num, 10) IF Rem > 4 THEN Count <- Count + 1 ENDIF Num <- DIV(Num, 10) ENDWHILE OUTPUT "Result: ", Count ```
Complete the trace table for the algorithm using the input value `7283`.
1 mark for correct values in `Rem` column in correct order (3, 8, 2, 7). 1 mark for correct sequence of values in `Num` column (7283, 728, 72, 7, 0). 1 mark for correct sequence of values in `Count` column (0, 1, 2). 0.5 marks for correct final output `Result: 2` (allow `2` or `"Result: ", 2`).
题目 10 · Trace Table & Algorithm Analysis
3.5 分
An algorithm is written to process elements of a 1D array `Values` containing 5 integers:
```text DECLARE Total, Index, CurrentVal : INTEGER // Array Values contains: [12, 5, 18, 7, 14] Total <- 0 FOR Index <- 1 TO 5 CurrentVal <- Values[Index] IF MOD(CurrentVal, 3) = 0 THEN Total <- Total + CurrentVal ENDIF NEXT Index OUTPUT Total ```
1 mark for correct `Index` values from 1 to 5 and corresponding `CurrentVal` values (12, 5, 18, 7, 14). 1 mark for initial `Total` of 0 and correct updates to `Total` (12, 30). 1 mark for no incorrect updates in `Total` on iterations where condition is false. 0.5 marks for correct final output `30`.
题目 11 · Logic Circuit Drawing & Truth Table
4 分
Complete the truth table for the following logic expression:
$$X = (\text{A} \text{ OR } \text{NOT } \text{B}) \text{ AND } (\text{B} \text{ XOR } \text{C})$$
4 marks total: - 4 marks for all 8 correct outputs in column X - 3 marks for 6 or 7 correct outputs - 2 marks for 4 or 5 correct outputs - 1 mark for 2 or 3 correct outputs - 0 marks for 0 or 1 correct output
A warehouse security system activates an alarm ($X = 1$) based on the states of three inputs:
- Motion sensor detects movement ($M = 1$) - Door sensor detects open door ($D = 1$) - System is armed by key switch ($S = 1$)
The alarm is activated ($X = 1$) if: - movement is detected $\text{AND}$ the system is armed $$\text{OR}$$ - the door is open $\text{AND}$ the system is armed $\text{AND}$ movement is $\text{NOT}$ detected.
(a) Write a logic expression for the alarm system output $X$. [2]
(b) Complete the truth table for the alarm system. [2]
(a) Deriving the logic expression: - First condition: movement detected AND system armed $\rightarrow (M \text{ AND } S)$ - Second condition: door open AND system armed AND movement NOT detected $\rightarrow (D \text{ AND } S \text{ AND NOT } M)$ - Combined with OR: $X = (M \text{ AND } S) \text{ OR } (D \text{ AND } S \text{ AND NOT } M)$
(b) Completing the truth table: - Row 1 ($0, 0, 0$): $(0 \text{ AND } 0) \text{ OR } (0 \text{ AND } 0 \text{ AND } 1) = 0 \text{ OR } 0 = 0$ - Row 2 ($0, 0, 1$): $(0 \text{ AND } 1) \text{ OR } (0 \text{ AND } 1 \text{ AND } 1) = 0 \text{ OR } 0 = 0$ - Row 3 ($0, 1, 0$): $(0 \text{ AND } 0) \text{ OR } (1 \text{ AND } 0 \text{ AND } 1) = 0 \text{ OR } 0 = 0$ - Row 4 ($0, 1, 1$): $(0 \text{ AND } 1) \text{ OR } (1 \text{ AND } 1 \text{ AND } 1) = 0 \text{ OR } 1 = 1$ - Row 5 ($1, 0, 0$): $(1 \text{ AND } 0) \text{ OR } (0 \text{ AND } 0 \text{ AND } 0) = 0 \text{ OR } 0 = 0$ - Row 6 ($1, 0, 1$): $(1 \text{ AND } 1) \text{ OR } (0 \text{ AND } 1 \text{ AND } 0) = 1 \text{ OR } 0 = 1$ - Row 7 ($1, 1, 0$): $(1 \text{ AND } 0) \text{ OR } (1 \text{ AND } 0 \text{ AND } 0) = 0 \text{ OR } 0 = 0$ - Row 8 ($1, 1, 1$): $(1 \text{ AND } 1) \text{ OR } (1 \text{ AND } 1 \text{ AND } 0) = 1 \text{ OR } 0 = 1$
(a) 2 marks: - 1 mark for $(M \text{ AND } S)$ - 1 mark for $(D \text{ AND } S \text{ AND NOT } M)$ correctly joined with $\text{OR}$ Accept equivalent correct expressions such as: $X = (M \text{ AND } S) \text{ OR } ((D \text{ AND } S) \text{ AND NOT } M)$
(b) 2 marks: - 2 marks for all 8 rows correct (0, 0, 0, 1, 0, 1, 0, 1) - 1 mark for 6 or 7 rows correct
题目 13 · short_answer
5 分
A garden nursery stores details of its plants in a database table named `PLANT_STOCK`.
Complete the Structured Query Language (SQL) script to display the plant name and price of all plants where the plant type is `'Perennial'` and the quantity in stock is at least 10.
The output must be sorted in ascending order of price.
ORDER BY .................................................................................................................. ```
查看答案详解收起答案详解
解题
To construct the SQL statement according to the requirements:
1. SELECT clause: We need to output the plant name and price. `SELECT PlantName, Price`
2. FROM clause: The data is retrieved from the `PLANT_STOCK` table. `FROM PLANT_STOCK`
3. WHERE clause: We must filter for plants of type `'Perennial'` AND a stock level of at least 10 (≥ 10 or > 9). `WHERE PlantType = 'Perennial'` `AND QuantityInStock >= 10`
4. ORDER BY clause: The list must be sorted by price in ascending order. `ORDER BY Price ASCENDING` (or `ORDER BY Price ASC` / `ORDER BY Price`)
评分标准
1 mark per correct line / section (total 5 marks):
- 1 mark for `PlantName, Price` (accept fields in either order) - 1 mark for `PLANT_STOCK` - 1 mark for `PlantType = 'Perennial'` (accept double quotes `"Perennial"`) - 1 mark for `AND QuantityInStock >= 10` (accept `AND QuantityInStock > 9`) - 1 mark for `Price ASCENDING` (accept `Price ASC` or `Price`)
Note: SQL keywords are case-insensitive. Allow follow-through if WHERE and AND lines are swapped or written on one line.
题目 14 · Short Pseudocode Writing
4 分
Write an algorithm in pseudocode that repeatedly prompts the user to enter an examination mark as an integer until a valid mark between 0 and 100 inclusive is entered.
Your algorithm must: - repeatedly input the mark until it is valid - output the message `"Invalid mark, please re-enter"` whenever an invalid mark is entered - output the message `"Mark accepted"` once a valid mark has been entered.
查看答案详解收起答案详解
解题
```text // Alternative 1: REPEAT ... UNTIL loop REPEAT OUTPUT "Enter mark (0 - 100): " INPUT Mark IF Mark < 0 OR Mark > 100 THEN OUTPUT "Invalid mark, please re-enter" ENDIF UNTIL Mark >= 0 AND Mark <= 100 OUTPUT "Mark accepted"
// Alternative 2: WHILE loop OUTPUT "Enter mark (0 - 100): " INPUT Mark WHILE Mark < 0 OR Mark > 100 DO OUTPUT "Invalid mark, please re-enter" INPUT Mark ENDWHILE OUTPUT "Mark accepted" ```
评分标准
1 mark for each point (max 4 marks): - 1 mark: Initial prompt and `INPUT` of mark. - 1 mark: Correct loop structure (e.g. `REPEAT ... UNTIL` or `WHILE ... DO`) with correct condition to continue while invalid / stop when valid. - 1 mark: Correct conditional check and output of error message `"Invalid mark, please re-enter"` when `Mark < 0 OR Mark > 100`. - 1 mark: Output of `"Mark accepted"` only after exiting the loop.
题目 15 · Short Pseudocode Writing
4 分
A 1D array `DailyRainfall` contains 30 `REAL` values representing rainfall measurements in millimetres for each day of a month (indices 1 to 30).
Write an algorithm in pseudocode to: - iterate through all 30 elements of `DailyRainfall` - count how many days had a rainfall measurement strictly greater than 15.0 mm - calculate the total rainfall recorded on those specific days - output the total rainfall and the count with suitable accompanying messages.
查看答案详解收起答案详解
解题
```text DECLARE Count : INTEGER DECLARE Total : REAL DECLARE Day : INTEGER
Count <- 0 Total <- 0.0 FOR Day <- 1 TO 30 IF DailyRainfall[Day] > 15.0 THEN Count <- Count + 1 Total <- Total + DailyRainfall[Day] ENDIF NEXT Day OUTPUT "Days with rainfall > 15mm: ", Count OUTPUT "Total rainfall on these days: ", Total ```
评分标准
1 mark for each point (max 4 marks): - 1 mark: Initialising both `Count` and `Total` to zero before the loop. - 1 mark: Correct loop iterating through the array from 1 to 30 (`FOR Day <- 1 TO 30 ... NEXT Day`). - 1 mark: Correct `IF` condition (`DailyRainfall[Day] > 15.0`) with correct incrementing of `Count` and accumulation of `Total`. - 1 mark: Output of both final `Count` and `Total` outside the loop with appropriate text messages.
题目 16 · Short Pseudocode Writing
4 分
Write a function `CountVowels` in pseudocode that takes a single `STRING` parameter `Sentence` and returns the integer count of all vowel characters (`'A'`, `'E'`, `'I'`, `'O'`, `'U'`) present in the string, regardless of case.
You should use standard pseudocode string handling routines such as `LENGTH`, `SUBSTRING`, and/or `UCASE`.
查看答案详解收起答案详解
解题
```text FUNCTION CountVowels(Sentence : STRING) RETURNS INTEGER DECLARE NumVowels, Index : INTEGER DECLARE NextChar : CHAR
NumVowels <- 0 FOR Index <- 1 TO LENGTH(Sentence) NextChar <- UCASE(SUBSTRING(Sentence, Index, 1)) IF NextChar = 'A' OR NextChar = 'E' OR NextChar = 'I' OR NextChar = 'O' OR NextChar = 'U' THEN NumVowels <- NumVowels + 1 ENDIF NEXT Index RETURN NumVowels ENDFUNCTION ```
评分标准
1 mark for each point (max 4 marks): - 1 mark: Correct function header with parameter and `RETURNS INTEGER`, and closing `ENDFUNCTION`. - 1 mark: Initialising counter variable to 0 and loop iterating from 1 to `LENGTH(Sentence)`. - 1 mark: Extracting single character using `SUBSTRING` and checking if vowel (handling uppercase/lowercase, e.g. via `UCASE` or checking both sets) and incrementing counter. - 1 mark: `RETURN` statement returning the vowel counter value.
题目 17 · Short Pseudocode Writing
4 分
A text file named `"Scores.txt"` stores a sequence of positive integer test scores, one value per line. The end of data is marked by a rogue (sentinel) value of `-1`.
Write an algorithm in pseudocode to: - open the file `"Scores.txt"` in read mode - read all the test scores from the file until `-1` is encountered - calculate the average score of all the test scores (excluding `-1`) - close the file - output the calculated average score with an appropriate message.
Assume there is at least one valid test score in the file before `-1`.
查看答案详解收起答案详解
解题
```text DECLARE Score, Total, Count : INTEGER DECLARE Average : REAL
OPENFILE "Scores.txt" FOR READ Total <- 0 Count <- 0 READFILE "Scores.txt", Score WHILE Score <> -1 DO Total <- Total + Score Count <- Count + 1 READFILE "Scores.txt", Score ENDWHILE CLOSEFILE "Scores.txt"
Average <- Total / Count OUTPUT "The average score is: ", Average ```
评分标准
1 mark for each point (max 4 marks): - 1 mark: `OPENFILE "Scores.txt" FOR READ` and `CLOSEFILE "Scores.txt"` correctly placed. - 1 mark: Reading initial value with `READFILE` and repeating with a `WHILE Score <> -1` loop reading subsequent values. - 1 mark: Totalling the scores and counting the number of scores inside the loop. - 1 mark: Correctly calculating average (`Total / Count`) after loop and outputting it with a suitable message.
题目 18 · Extended Scenario-based Algorithm Design
15 分
A local sports club manages a youth summer camp with 40 available places.
The following one-dimensional (1D) arrays are used to store details of the registered campers, where the index represents each camper (from 1 to 40): - `CamperName[1:40]` stores the name of each camper (STRING) - `CamperAge[1:40]` stores the age of each camper (INTEGER) - `CamperSport[1:40]` stores the chosen sport code (STRING: "T" for Tennis, "S" for Swimming, "A" for Athletics) - `CamperFee[1:40]` stores the final calculated fee for each camper in dollars (REAL)
Write an algorithm using pseudocode or program code to meet the following requirements:
1. Input and Validation: - Prompt and input data for all 40 campers. - Ensure the name is not empty (presence check). - Validate that the age is an integer between 7 and 14 inclusive (range check). - Validate that the sport code is either "T", "S", or "A". - Prompt the user again if any input is invalid until valid data is entered.
2. Fee Calculation: - The standard base fee is $120.00. - If the camper is under 10 years old (age < 10), a discount of $15.00 is subtracted from the base fee. - If the chosen sport is Tennis ("T"), an equipment surcharge of $20.00 is added to the fee. - Store the calculated fee in `CamperFee`.
3. Display and Summary Statistics: - Output the name, age, sport code, and calculated fee for each of the 40 campers. - Calculate and output: - The total revenue collected across all 40 campers. - The average age of all campers. - The total number of campers enrolled in each sport ("T", "S", and "A"). - The name of the camper(s) who paid the highest fee.
查看答案详解收起答案详解
解题
// Declare arrays DECLARE CamperName : ARRAY[1:40] OF STRING DECLARE CamperAge : ARRAY[1:40] OF INTEGER DECLARE CamperSport : ARRAY[1:40] OF STRING DECLARE CamperFee : ARRAY[1:40] OF REAL
// Declare variables DECLARE Index : INTEGER DECLARE TotalRevenue : REAL DECLARE TotalAge : INTEGER DECLARE AverageAge : REAL DECLARE CountTennis : INTEGER DECLARE CountSwimming : INTEGER DECLARE CountAthletics : INTEGER DECLARE MaxFee : REAL
// 1. Input, validation, fee calculation and array storage FOR Index <- 1 TO 40 // Input and validate name REPEAT OUTPUT "Enter name for camper ", Index, ": " INPUT CamperName[Index] UNTIL CamperName[Index] <> ""
// Input and validate age REPEAT OUTPUT "Enter age (7-14) for camper ", Index, ": " INPUT CamperAge[Index] UNTIL CamperAge[Index] >= 7 AND CamperAge[Index] <= 14
// Input and validate sport code REPEAT OUTPUT "Enter sport code (T for Tennis, S for Swimming, A for Athletics): " INPUT CamperSport[Index] UNTIL CamperSport[Index] = "T" OR CamperSport[Index] = "S" OR CamperSport[Index] = "A"
// 2. Fee Calculation CamperFee[Index] <- 120.00 IF CamperAge[Index] < 10 THEN CamperFee[Index] <- CamperFee[Index] - 15.00 ENDIF IF CamperSport[Index] = "T" THEN CamperFee[Index] <- CamperFee[Index] + 20.00 ENDIF
IF CamperSport[Index] = "T" THEN CountTennis <- CountTennis + 1 ELSE IF CamperSport[Index] = "S" THEN CountSwimming <- CountSwimming + 1 ELSE CountAthletics <- CountAthletics + 1 ENDIF ENDIF
// Track maximum fee IF CamperFee[Index] > MaxFee THEN MaxFee <- CamperFee[Index] ENDIF NEXT Index
// 3. Display individual camper records OUTPUT "--- CAMPER DETAILS ---" FOR Index <- 1 TO 40 OUTPUT "Name: ", CamperName[Index], " | Age: ", CamperAge[Index], " | Sport: ", CamperSport[Index], " | Fee: $", CamperFee[Index] NEXT Index
// Calculate average age AverageAge <- TotalAge / 40.0
// Display summary statistics OUTPUT "--- SUMMARY STATISTICS ---" OUTPUT "Total revenue collected: $", TotalRevenue OUTPUT "Average age of campers: ", AverageAge OUTPUT "Campers in Tennis: ", CountTennis OUTPUT "Campers in Swimming: ", CountSwimming OUTPUT "Campers in Athletics: ", CountAthletics
// Display camper(s) with the highest fee OUTPUT "Camper(s) paying the highest fee of $", MaxFee, ":" FOR Index <- 1 TO 40 IF CamperFee[Index] = MaxFee THEN OUTPUT CamperName[Index] ENDIF NEXT Index
评分标准
Marking is split into two assessment objectives: AO2 (Application & Technique - 9 marks) and AO3 (Evaluation, Logic & Structure - 6 marks).
### AO2: Specific Functional Marks (Max 9 marks) - Input & Validation (3 marks): - 1 mark: Loop with presence check for non-empty camper name. - 1 mark: Loop with range check for age (≥ 7 AND ≤ 14). - 1 mark: Loop validating sport code ("T", "S", or "A"). - Fee Calculation & Storage (2 marks): - 1 mark: Base fee ($120) adjusted correctly for age < 10 (-$15) and Tennis (+$20). - 1 mark: Correctly storing name, age, sport code, and calculated fee in parallel arrays. - Totals & Counting (2 marks): - 1 mark: Totalling overall revenue and accumulating age/counting per sport. - 1 mark: Correct calculation of average age (`TotalAge / 40`). - Output & Highest Fee Search (2 marks): - 1 mark: Iterating and displaying individual camper details and summary statistics. - 1 mark: Correct algorithm to identify and output the name(s) of camper(s) paying the maximum fee.
### AO3: Programming Logic & Structure (Max 6 marks) - Level 3 (5–6 marks): - The algorithm is fully functional, robust, and well-structured. - Appropriate control structures (FOR, REPEAT...UNTIL / WHILE, IF/CASE) used effectively. - Meaningful identifier names throughout, clear comments, and consistent indentation. - Level 2 (3–4 marks): - The algorithm addresses most requirements but may have minor logical flaws (e.g., slight off-by-one errors or minor logic omissions in max search). - Readable code with mostly consistent naming conventions and structure. - Level 1 (1–2 marks): - Partial solution addressing only isolated parts of the scenario. - Weak control structures, syntax inconsistent with standard pseudocode, lack of commenting/indentation. - 0 marks: No creditable response.
想知道自己有几分把握?
thinka 是 DSE 学生在用的 AI 练习应用,提供无限量练习题、即时自动批改和详细解题步骤。超过 100,000 名学生用它确认自己是真的会,而不只是「以为会」。