Arithmetic, Relational & Boolean Operations (AQA GCSE Computer Science): Revision Note
Exam code: 8525
Arithmetic, Relational & Boolean Operations
What is an operator?
An operator is a symbol used to instruct a computer to perform a specific operation on one or more values
Examples of common operators include:
Arithmetic
Relational
Boolean (AND, OR and NOT)
Arithmetic Operators
What are the arithmetic operators?
Operator | Pseudocode | Python |
Addition |
|
|
Subtraction |
|
|
Multiplication |
|
|
Division |
|
|
Modulus (remainder after division) |
|
|
Quotient (whole number division) |
|
|
Exponentiation (to the power of) |
|
|
To demonstrate the use of common arithmetic operators, three sample programs written in Python are given below
Comments have been included to help understand how the arithmetic operators are being used
Arithmetic operators #1 - a simple program to calculate if a user entered number is odd or even
Arithmetic operators #2 - a simple program to calculate the area of a circle from a user inputted radius
Arithmetic operators #3 - a simple program that generates 5 maths questions based on user inputs and gives a score of how many were correctly answered at the end
Python code |
---|
|
Relational & Boolean Operators
What are the relational operators?
Operator | Pseudocode | Python |
Equal to |
|
|
Not equal to |
|
|
Less than |
|
|
Less than or equal to |
|
|
Greater than |
|
|
Greater than or equal to |
|
|
What are the boolean operators?
Boolean operators are
AND
OR
NOT
To demonstrate the use of common Relational and Boolean operators, three sample programs written in Python are given below
Comments have been included to help understand how the Boolean operators are being used
Common Boolean operators #1 - a simple program that assigns Boolean values to two variables and outputs basic comparisons
Common Boolean operators #2 - a simple program to output a grade based on a users score
Common Boolean operators #3 - a simple program reads a text files and searches for an inputted score
Python code |
---|
|
Worked Example
A cinema calculates ticket prices based on age category
Adult = £13.00
Child = £7.50
The program asks the user to enter their age and calculates the cost of their ticket
A simple algorithm is used
adult = 13.00
child = 7.50
age = input("What is your age: ")
if age > 18 then
total_cost = adult
else
total_cost = child
end if
print(total_cost)
The cinema decides to add a discount of 25% to customers who come to the cinema on 'Sunday evening'
Identify all the additional inputs that will be required for this change to the algorithm [2]
How to answer this question
What new information is needed?
Answer
day
time
You've read 1 of your 5 free revision notes this week
Unlock more, it's free!
Did this page help you?