AQA GCSE Computer Science Past Papers | Mark Schemes

Match AQA paper and programming-language variants before practising Boolean logic and tracing algorithms.

Quick Answer

The AQA GCSE Computer Science archive includes question papers and mark schemes, including GCSE Computer Science Paper 1A – Computational Thinking and Programming Skills (C#). Match the assessment code and series before using the scheme to check your working.

A flowchart notebook beside a computer keyboard
Advertisement

AQA GCSE Computer Science 9-1 (Old Specification)

AQA GCSE Computer Science 9-1 (Old Specification) June 2015

AQA GCSE Computer Science 9-1 (Old Specification) June 2014

Advertisement

Trace a loop with a boundary case

A program starts a total at zero and adds every value that is at least five from the list four, five, eight. After four, the total stays zero. Five qualifies because the comparison includes equality, so the total becomes five. Eight takes it to thirteen. Draw a trace table with a row for each input and a separate column for the condition. A final output of eight suggests the program tested strictly greater than five.

Use and Apply the Conditional to Construct a Truth Table

A conditional is a logical statement of the form if p, then q. The conditional statement in logic is a promise or contract. The only time the conditional, p→q, is false is when the contract or promise is broken.
For example, consider the following scenario. A child’s parent says, “If you do your homework, then you can play your video games.” The child really wants to play their video games, so they get started right away, finish within an hour, and then show their parent the completed homework. The parent thanks the child for doing a great job on their homework and allows them to play video games. Both the parent and child are happy. The contract was satisfied; true implies true is true.
Now, suppose the child does not start their homework right away, and then struggles to complete it. They eventually finish and show it to their parent. The parent again thanks the child for completing their homework, but then informs the child that it is too late in the evening to play video games, and that they must begin to get ready for bed. Now, the child is really upset. They held up their part of the contract, but they did not receive the promised reward. The contract was broken; true implies false is false.
So, what happens if the child does not do their homework? In this case, the hypothesis is false. No contract has been entered, therefore, no contract can be broken. If the conclusion is false, the child does not get to play video games and might not be happy, but this outcome is expected because the child did not complete their end of the bargain. They did not complete their homework. False implies false is true. The last option is not as intuitive. If the parent lets the child play video games, even if they did not do their homework, neither parent nor child are going to be upset. False implies true is true.
The truth table for the conditional statement below summarizes these results.
p q p→q
T T T
T F F
F T T
F F T

Constructing Truth Tables for Conditional Statements

Assume both of the following statements are true: p: My sibling washed the dishes, and q: My parents paid them $5.00. Create a truth table to determine the truth value of each of the following conditional statements.
  1. p→q
  2. p→ ~q
  3. ~p→q
Solution
  1. Because p is true and q is true, the statement p→q is, “If my sibling washed the dishes, then my parents paid them $5.00.” My sibling did wash the dishes, since p is true, and the parents did pay the sibling $5.00, so the contract was entered and completed. The conditional statement is true, as indicated by the truth table representing this case: T → T = T.
    p q p→q
    T T T
  2. p→~q translates to the statement, “If my sibling washed the dishes, then my parents did not pay them $5.00.” p is true, but ~q is false. The sibling completed their end of the contract, but they did not get paid. The contract was broken by the parents. The conditional statement is false, as indicated by the truth table representing this case: T → F = F.
    p q ~q p→ ~q
    T T F F
  3. ~p→q translates to the statement, “If my sibling did not wash the dishes, then my parents paid them $5.00.” ~p is false, but q is true. The sibling did not do the dishes. No contract was entered, so it could not be broken. The parents decided to pay them $5.00 anyway. The conditional statement is true, as indicated by the truth table representing this case: F → T = T.
    p q ~p ~p→q
    T T F T

Determining Validity of Conditional Statements

Construct a truth table to analyze all possible outcomes for each of the following statements then determine whether they are valid.
  1. p∧q→~q
  2. p→~p∨q
Solution
  1. Applying the dominance of connectives, the statement p∧q→ ~q is equivalent to (p∧q)→(~q). So, the columns of the truth table will include p, q, p∧q, ~q, and p∧q→ ~q. Because there are only two basic propositions, p and q, the table will have 2(2)=4 rows of truth values to account for all the possible outcomes. The statement is not valid because the last column is not all true.
    p q p∧q ~q p∧q→ ~q
    T T T F F
    T F F T T
    F T F F T
    F F F T T
  2. Applying the dominance of connectives, the statement p→ ~p∨q is equivalent to (p)→ ((~p)∨q). So, the columns of the truth table will include p, q, ~p, ~p∨q, and p→ (~p∨q). Because there are only two basic propositions, p and q, the table will have 2(2)=4 rows of truth values to account for all the possible outcomes. The statement is not valid because the last column is not all true.
    p q ~p ~p∨q p→ (~p∨q)
    T T F T T
    T F F F F
    F T T T T
    F F T T T

Use and Apply the Biconditional to Construct a Truth Table

The biconditional, p↔q, is a two way contract; it is equivalent to the statement (p→q)∧(q→p). A biconditional statement, p↔q, is true whenever the truth value of the hypothesis matches the truth value of the conclusion, otherwise it is false.
The truth table for the biconditional is summarized below.
p q p↔q
T T T
T F F
F T F
F F T

Constructing Truth Tables for Biconditional Statements

Assume both of the following statements are true: p: The plumber fixed the leak, and q: The homeowner paid the plumber $150.00. Create a truth table to determine the truth value of each of the following biconditional statements.
  1. p↔q
  2. p↔ ~q
  3. ~p↔ ~q
Solution
  1. Because p is true and q is true, the statement p↔q is “The plumber fixed the leak if and only if the homeowner paid them $150.00.” Because both p and q are true, the leak was fixed and the plumber was paid, meaning both parties satisfied their end of the bargain. The biconditional statement is true, as indicated by the truth table representing this case: T ↔ T = T.
    p q p↔q
    T T T
  2. p→~q translates to the statement, “The plumber fixed the leak if and only if the homeowner did not pay them $150.” If the plumber fixed the leak and the homeowner did not pay them, the homeowner will have broken their end of the contract. The biconditional statement is false, as indicated by the truth table representing this case: T ↔ F = F.
    p q ~q p↔ ~q
    T T F F
  3. ~p↔ ~q translates to the statement, “The plumber did not fix the leak if and only if the homeowner did not pay them $150.” In this case, neither party—the plumber nor the homeowner—entered into the contract. The leak was not repaired, and the plumber was not paid. No agreement was broken. The biconditional statement is true, as indicated by the truth table representing this case: F ↔ F = T.
    p q ~p ~q ~p↔ ~q
    T T F F T

Determining Validity of Biconditional Statements

Construct a truth table to analyze all possible outcomes for each of the following statements, then determine whether they are valid.
  1. p∧q↔p∧~q
  2. p∨q↔~p∨q
  3. p→q↔~q→~p
  4. p∧q→~r↔p∧q∧r
Solution
  1. Applying the dominance of connectives, the statement p∧q↔ p∧~q is equivalent to (p∧q)↔ (p∧(~q)). So, the columns of the truth table will include p, q, p∧q, ~q, p∧~q and (p∧q)↔(p∧~q). Because there are only two basic propositions, p and q, the table will have 2(2)=4 rows of truth values to account for all the possible outcomes. The statement is not valid because the last column is not all true.
    p q p∧q ~q p∧~q (p∧q)↔(p∧~q)
    T T T F F F
    T F F T T F
    F T F F F T
    F F F T F T
  2. Applying the dominance of connectives, the statement p∨q↔~p∨q is equivalent to (p∨q)↔ ((~p)∨q). So, the columns of the truth table will include p, q, p∨q, ~p, ~p∨q, and (p∨q)↔(~p∨q). Because there are only two basic propositions, p and q, the table will have 2(2)=4 rows of truth values to account for all the possible outcomes. The statement is not valid because the last column is not all true.
    p q p∨q ~p ~p∨q (p∨q)↔(~p∨q)
    T T T F T T
    T F T F F F
    F T T T T T
    F F F T T F
  3. Applying the dominance of connectives, the statement p→q↔ ~q→~p is equivalent to (p→q)↔ ((~q)→(~p)). So, the columns of the truth table will include p, q, p→q, ~q, ~p, ~q→~p, and (p→q)↔(~q→ ~p). Because there are only two basic propositions, p and q the table will have 2(2)=4 rows of truth values to account for all the possible outcomes. The statement is valid because the last column is all true.
    p q p→q ~q ~p ~q→~p (p→q)↔(~q→~p)
    T T T F F T T
    T F F T F F T
    F T T F T T T
    F F T T T T T
  4. Applying the dominance of connectives, the statement p∧q→ ~r ↔ p∧q∧r is equivalent to ((p∧q)→(~r)) ↔ ((p∧q)∧r). So, the columns of the truth table will include p, q, r, ~r, p∧q, (p∧q)∧ ~r, (p∧q)∧r, and ((p∧q)→(~r)) ↔ ((p∧q)∧r). Because there are three basic propositions, p, q, and r, the table will have 2(2)(2)=8 rows of truth values to account for all the possible outcomes. The statement is not valid because the last column is not all true.
    p q r ~r p∧q (p∧q)→~r (p∧q)∧r (p∧q→~r)↔(p∧q∧r)
    T T T F T F T T
    T T F T T T F T
    T F T F F T F F
    T F F T F T F F
    F T T F F T F F
    F T F T F T F F
    F F T F F T F F
    F F F T F T F F

Check Your Understanding

Video

  • Logic Part 8: The Conditional and Tautologies
  • Logic Part 11B Biconditional and Summary of Truth Value Rules in Logic
  • Logic Part 13: Truth Tables to Determine if Argument is Valid or Invalid

Interpret and Apply Negations, Conjunctions, and Disjunctions

The negation of a statement will have the opposite truth value of the original statement. When p is true, ~p is false, and when p is false, ~p is true.

Finding the Truth Value of a Negation

For each logical statement, determine the truth value of its negation.
  1. p: 3+5=8.
  2. q: All horses are mustangs.
  3. ~r: New Delhi is not the capital of India.
Solution
  1. p is true because 3 + 5 does equal 8; therefore, the negation of p, ~p:3+5≠8, is false.
  2. q is false because there are other types of horses besides mustangs, such as Clydesdales or Arabians; therefore, the negation of q, ~q, is true.
  3. ~r is false because New Delhi is the capital of India; therefore, the negation of ~r, r, is true.
A conjunction is a logical and statement. For a conjunction to be true, both statements that make up the conjunction must be true. If at least one of the statements is false, the and statement is false.

Finding the Truth Value of a Conjunction

Given p: 4+7=11, q: 11-3=7, and r: 7×11=77, determine the truth value of each conjunction.
  1. p∧q
  2. ~q∧r
  3. ~p∧q
Solution
  1. p is true, and q is false. Because one statement is true, and the other statement is false, this makes the complete conjunction false.
  2. q is false, so ~q is true, and r is true. Therefore, both statements are true, making the complete conjunction true.
  3. ~p is false, and q is false. Because both statements are false, the complete conjunction is false.
A disjunction is a logical inclusive or statement, which means that a disjunction is true if one or both statements that form it are true. The only way a logical inclusive or statement is false is if both statements that form the disjunction are false.

Finding the Truth Value of a Disjunction

Given p: 4+7=11, q: 11-3=7, and r: 7×11=77, determine the truth value of each disjunction.
  1. p∨q
  2. ~q∨r
  3. ~p∨q
Solution
  1. p is true, and q is false. One statement is true, and one statement is false, which makes the complete disjunction true.
  2. q is false, so ~q is true, and r is true. Therefore, one statement is true, and the other statement is true, which makes the complete disjunction true.
  3. ~p is false, and q is false. When all of the component statements are false, the disjunction is false.
In the next example, you will apply the dominance of connectives to find the truth values of compound statements containing negations, conjunctions, and disjunctions and use a table to record the results. When constructing a truth table to analyze an argument where you can determine the truth value of each component statement, the strategy is to create a table with two rows. The first row contains the symbols representing the components that make up the compound statement. The second row contains the truth values of each component below its symbol. Include as many columns as necessary to represent the value of each compound statement. The last column includes the complete compound statement with its truth value below it.

Finding the Truth Value of Compound Statements

Given p:4+7=11, q:11-3=7, and r:7×11=77, construct a truth table to determine the truth value of each compound statement
  1. ~p∧q∨r
  2. ~p∨q∧r
  3. ~(p∧r)∨q
Solution
  1. Step 1: The statement “~p∧q∨r” contains three basic logical statements, p, q, and r, and three connectives, ~,∧,∨. When we place parentheses in the statement to indicate the dominance of connectives, the statement becomes (((~p)∧q)∨r). Step 2: After we have applied the dominance of connectives, we create a two row table that includes a column for each basic statement that makes up the compound statement, and an additional column for the contents of each parentheses. Because we have three sets of parentheses, we include a column for ~p, the innermost parentheses, a column for (~p)∧q, the next set of parentheses, and ((~p)∧q)∨r in the last column for the third parentheses. Step 3: Once the table is created, we determine the truth value of each statement starting from left to right. The truth values of p, q, and r are true, false, and true, respectively, so we place T, F, and T in the second row of the table. Because p is true, ~p is false. Step 4: Next, evaluate ~p∧q from the table: ~p is false, and q is also false, so ~p∧q is false, because a conjunction is only true if both of the statements that make it are true. Place an F in the table below its heading. Step 5: Finally, using the table, we understand that (~p∧q) is false and r is true, so the complete statement (~p∧q)∨r is false or true, which is true (because a disjunction is true whenever at least one of the statements that make it is true). Place a T in the last column of the table. The complete statement ~p∧q∨r is true.
    p q r ~p (~p)∧q ((~p)∧q)∨r
    T F T F F T
  2. Step 1: Applying the dominance of connectives to the original compound statement ~p∨q∧r, we get (((~p)∨q)∧r). Step 2: The table needs columns for p,q,r,~p,(~p)∨q, and ((~p)∨q)∧r. Step 3:The truth values of p, q, r, and ~p are the same as in Question 1. Step 4: Next, ~p∨q is false or false, which is false, so we place an F below this statement in the table. This is the only time that a disjunction is false. Step 5: Finally, ~p∨q and r are the conjunction of the statements, ~p∨q and r, and so the expressions evaluate to false and true, which is false. Recall that the only time an "and" statement is true is when both statements that form it are also true. The complete statement ~p∨q∧r is false.
    p q r ~p (~p)∨q ((~p)∨q)∧r
    T F T F F F
  3. Step 1: Applying the dominance of connectives to the original statement, we have: ((~(p∧r))∨q). Step 2: So, the table needs the following columns: p,q,r,p∧r,~(p∧r), and ~(p∧r)∨q. Step 3: The truth values of p, q, and r are the same as in Questions 1 and 2. Step 4: From the table it can be seen that p∧r is true and true, which is true. So the negation of p and r is false, because the negation of a statement always has the opposite truth value of the original statement. Step 5: Finally, ~(p∧r)∨q is the disjunction of ~(p∧r) with q, and so we have false or false, which makes the complete statement false.
    p q r p∧r ~(p∧r) ~(p∧r)∨q
    T F T T F F

Construct Truth Tables to Analyze All Possible Outcomes

Recall from Statements and Questions that the negation of a statement will always have the opposite truth value of the original statement; if a statement p is false, then its negation ~p is true, and if a statement p is true, then its negation ~p is false. To create a truth table for the negation of statement p, add a column with a heading of ~p, and for each row, input the truth value with the opposite value of the value listed in the column for p, as depicted in the table below.
Negation
p ~p
T F
F T
Conjunctions and disjunctions are compound statements formed when two logical statements combine with the connectives “and” and “or” respectively. How does that change the number of possible outcomes and thus determine the number of rows in our truth table? The multiplication principle, also known as the fundamental counting principle, states that the number of ways you can select an item from a group of n items and another item from a group with m items is equal to the product of m and n. Because each proposition p and q has two possible outcomes, true or false, the multiplication principle states that there will be 2×2=4 possible outcomes: {TT, TF, FT, FF}.
The tree diagram and table in diagram demonstrate the four possible outcomes for two propositions p and q.
A horizontal flowchart and a table with five rows and three columns.
A conjunction is a logical and statement. For a conjunction to be true, both the statements that make up the conjunction must be true. If at least one of the statements is false, the and statement is false.
A disjunction is a logical inclusive or statement. Which means that a disjunction is true if one or both statements that make it are true. The only way a logical inclusive or statement is false is if both statements that make up the disjunction are false.
Conjunction (AND) Disjunction (OR)
p q p∧q p q p∨q
T T T T T T
T F F T F T
F T F F T T
F F F F F F

Constructing Truth Tables to Analyze Compound Statements

Construct a truth table to analyze all possible outcomes for each of the following arguments.
  1. p∨~q
  2. ~(p∧q)
  3. (p∨~q)∧r
Solution
  1. Step 1: Because there are two basic statements, p and q, and each of these has two possible outcomes, we will have 2(2)=4 rows in our table to represent all possible outcomes: TT, TF, FT, and FF. The columns will include p, q, ~q, and p∨~q. Step 2: Every value in column ~q will have the opposite truth value of the corresponding value in column q: F, T, F, and T. Step 3: To complete the last column, evaluate each element in column p with the corresponding element in column ~q using the connective or.
    p q ~q p∨~q
    T T F T
    T F T T
    F T F F
    F F T T
  2. Step 1: The columns will include p, q, p∧q, and ~(p∧q). Because there are two basic statements, p and q, the table will have four rows to account for all possible outcomes. Step 2: The p∧q column will be completed by evaluating the corresponding elements in columns p and q respectively with the and connective. Step 3: The final column, ~(p∧q), will be the negation of the p∧q column.
    p q p∧q ~(p∧q)
    T T T F
    T F F T
    F T F T
    F F F T
  3. Step 1: This statement has three basic statements, p, q, and r. Because each basic statement has two possible truth values, true or false, the multiplication principal indicates there are 2(2)(2)=8 possible outcomes. So eight rows of outcomes are needed in the truth table to account for each possibility. Half of the eight possibilities must be true for the first statement, and half must be false. Step 2: So, the first column for statement p, will have four T’s followed by four F’s. In the second column for statement q, when p is true, half the outcomes for q must be true and the other half must be false, and the same pattern will repeat for when p is false. So, column q will have TT, FF, FF, FF. Step 3: The column for the third statement, r, must alternate between T and F. Once, the three basic propositions are listed, you will need a column for~q, p∨~q, and (p∨~q)∧r. Step 4: The column for the negation of q, ~q, will have the opposite truth value of each value in column q. Step 5: Next, fill in the truth values for the column containing the statement p∨~q. The or statement is true if at least one of p or ~q is true, otherwise it is false. Step 6: Finally, fill in the column containing the conjunction (p∨~q)∧r. To evaluate this statement, combine column p∨~q and column r with the and connective. Recall, that only time "and" is true is when both values are true, otherwise the statement is false. The complete truth table is:
    p q r ~q p∨~q (p∨~q)∧r
    T T T F T T
    T T F F T F
    T F T T T T
    T F F T T F
    F T T F F F
    F T F F F F
    F F T T T T
    F F F T T F

Determine the Validity of a Truth Table for a Compound Statement

A logical statement is valid if it is always true regardless of the truth values of its component parts. To test the validity of a compound statement, construct a truth table to analyze all possible outcomes. If the last column, representing the complete statement, contains only true values, the statement is valid.

Determining the Validity of Compound Statements

Construct a truth table to determine the validity of each of the following statements.
  1. ~p∧q
  2. ~(p∧~p)
Solution
  1. Step 1: Because there are two statements, p and q, and each of these has two possible outcomes, there will be 2(2)=4 rows in our table to represent all possible outcomes: TT, TF, FT, and FF. Step 2: The columns, will include p, q, ~p and ~p∧q. Every value in column ~p will have the opposite truth value of the corresponding value in column p. Step 3: To complete the last column, evaluate each element in column ~p with the corresponding element in column q using the connective and . The last column contains at least one false, therefore the statement ~p∧q is not valid.
    p q ~p ~p∧q
    T T F F
    T F F F
    F T T T
    F F T F
  2. Step 1: Because the statement ~(p∧~p) only contains one basic proposition, the truth table will only contain two rows. Statement p may be either true or false. Step 2: The columns will include p, ~p, p∧~p, and ~(p∧~p). Evaluate column p∧~p with the and connective, because the symbol ∧ represents a conjunction or logical and statement. True and false is false, and false and true is also false. Step 3: The final column is the negation of each entry in the third column, both of which are false, so the negation of false is true. Because all the truth values in the final column are true, the statement ~(p∧~p) is valid.
    p ~p p∧~p ~(p∧~p)
    T F F T
    F T F T

Check Your Understanding

Video

  • Logic Part 2: Truth Values of Conjunctions: Is an "AND" statement true or false?
  • Logic Part 3: Truth Values of Disjunctions: Is an "OR" statement true or false?
  • Logic Part 4: Truth Values of Compound Statements with "and", "or", and "not"
  • Logic Part 5: What are truth tables? How do you set them up?
  • Logic Part 6: More on Truth Tables and Setting Up Rows and Column Headings

Law of Detachment

The law of detachment is a valid form of a conditional argument that asserts that if both the conditional, p→q, and the hypothesis, p, are true, then the conclusion q must also be true. The law of detachment is also called affirming the hypothesis (or antecedent) and modus ponens. Symbolically, it has the form ((p→q)∧p)→q.
Law of Detachment
Premise: p→q
Premise: p
Conclusion: ∴ q
Looking at the truth table for the conditional statement, the only time the conditional is true is when the hypothesis p is also true. The only place this happens is in the first row, where q is also true, confirming that the law of detachment is a valid argument.
p q p→q
T T T
T F F
F T T
F F T
Another way to verify that the law of detachment is a valid argument is to construct a truth table for the argument ((p→q)∧p)→q and verify that it is a tautology.
p q p→q (p→q)∧p ((p→q)∧p)→q
T T T T T
T F F F T
F T T F T
F F T F T
Venn diagrams may also be used to verify deductive arguments, which include conditional premises. Consider the statement p→q: “If you play guitar, then you are a musician.” The set of guitarists is a subset of the set of musicians, p⊂q. To verify that an argument is valid using a Venn diagram, draw the Venn diagram representing all the premises in the argument only, as shown in diagram. Then verify if the conclusion is also represented by the Venn diagram of the premises. If it is, the argument is valid. If it is not, the argument is not valid. The set of guitarists is drawn as a subset of the set of musicians to represent the premise, p→q. The × represents the premise: p is true. This completes the drawing of the premises.
A chart shows a large and a small circle. The chart is titled U is equal to people. A small circle labeled p is equal to guitarists is labeled inside a large circle labeled q is equal to musicians. An 'x' mark is indicated in the center of the small circle.
Now, examine the Venn diagram to verify if the conclusion is included in the picture. The conclusion is q. Because the × is in the set p, and p is a subset of q, × is also in q; therefore, the law of detachment is a valid argument.

Applying the Law of Detachment to Determine a Valid Conclusion

Each pair of statements represents the premises in a logical argument. Based on these premises, apply the law of detachment to determine a valid conclusion.
  1. If Leonardo da Vinci was an artist, then he painted the Mona Lisa. Leonardo da Vinci was an artist.
  2. If Michael Jordan played for the Chicago Bulls, then Michael Jordan was not a soccer player. Michael Jordan played for the Chicago Bulls.
  3. If all fish have gills, then clown fish have gills. All fish have gills.
Solution
  1. The premises are p→q: If Leonardo da Vinci was an artist, then he painted the Mona Lisa, and p: Leonardo da Vinci was an artist. This argument has the form of the law of detachment, so, the conclusion is q: Leonardo da Vinci painted the Mona Lisa.
  2. The premises follow the form of the law of detachment, so a valid conclusion would be q. The premises are p→q: If Michael Jordan played for the Chicago Bulls, then Michael Jordan was not a soccer player, and p: Michael Jordan played for the Chicago Bulls. The conclusion that follows from the premises is q: Michael Jordan was not a soccer player.
  3. The premises are p→q: If all fish have gills, then clown fish have gills, and p: All fish have gills. This argument has the form of the law of detachment, so the conclusion is q: clown fish have gills.