0% found this document useful (0 votes)
4 views

A Level Computer Science 2024

The document contains truth tables for logical expressions involving NOT, AND, and OR operations. It also includes a Python program that modifies the value of 'a' based on conditions involving 'b' and 'c', along with test data and expected outcomes. Additionally, there is a section on converting between denary, binary, and hexadecimal values.

Uploaded by

pikagaming9666
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

A Level Computer Science 2024

The document contains truth tables for logical expressions involving NOT, AND, and OR operations. It also includes a Python program that modifies the value of 'a' based on conditions involving 'b' and 'c', along with test data and expected outcomes. Additionally, there is a section on converting between denary, binary, and hexadecimal values.

Uploaded by

pikagaming9666
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

(a) Write the truth tables for the expressions NOT (A AND B)

A B A AND B NOT(A AND


B)
0 0 0 1

0 1 0 1

1 0 0 1

1 1 1 0

(b) ((NOT A) OR (NOT B))

A B NOT A NOT B (NOT A)


OR
(NOT B)
0 0 1 1 1

0 1 1 0 1

1 0 0 1 1

1 1 0 0 0

2. What do you notice about these tables?

They are truth tables


3. Design and create a program to ask for an input of ‘a’, ‘b’ and ‘c’ and then
output the value of ‘a’ after this statement has been executed:

IF (a < b) OR (b < c) THEN a = b

Program in python would be:

# Get inputs for a, b, and c from the user


a = float(input("Enter value for a: "))
b = float(input("Enter value for b: "))
c = float(input("Enter value for c: "))

# Apply the condition


if (a < b) or (b < c):
a=b
# Output the value of a
print("The value of a after execution is:", a)
4. Decide on suitable test data for this program giving a reason for each
combination of values for a, b and c, give your expected result and the actual
result for each.

Values Reason Expected Actual


a=1, b=2, c=3 a<b, b<c a=b=2 2

a = 3, b = 5, c = 4 The condition (a < a=5 a=5


b) is true, so a
should be set to b
a = 7, b = 6, c = 8 he condition (b < a=6 a=6
c) is true, so a
should be set to b.
a = 4, b = 4, c = 10 The condition (b < a=4 a = 4
c) is true, so a
should be set to b.

Checkpoint Task 3
On the next page, complete the table
Data types, data structures and algorithms

Activity:
Converting between denary, binary and hex
Binary value plus
No. Denary Binary Hex
00011110

1 1 00000001 01 00100000

2 5 00000101 05 00100011

3 10 00001010 0A 00101000

4 22 00010110 16 00110100

5 40 00101000 28 01000110

6 77 01001101 4D 01101011

7 91 01011011 5B 01111001

8 121 01111001 79 10010111

9 144 10010000 90 10101110

10 168 10101000 A8 11000110

11 170 10101010 AA 11001000

12 200 11001000 C8 11100110

13 211 11010011 D3 11110001

You might also like