Programming Operators (Edexcel GCSE Computer Science)
Revision Note
Programming Arithmetic Operators
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 enters 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 examples |
---|
# ----------------------------------------------------------------------- # if the remainder of the number divided by 2 is 0, the number is even # ----------------------------------------------------------------------- # Calculate the area of the circle # Display the calculated area # ------------------------------------------------------------------------ # Loop 5 times # Check the answer and update the score
|
Programming Boolean & Relational Operators
To demonstrate the use of common 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
Boolean operators #1 - a simple program that assigns Boolean values to two variables and outputs basic comparisons
Boolean operators #2 - a simple program to output a grade based on a users score
Boolean operators #3 - a simple program reads a text files and searches for an inputted score
Python examples |
---|
# ----------------------------------------------------------- # print the result of a and b # ----------------------------------------------------------- # Take input for the score from the user # Compare the score and output the corresponding grade # ----------------------------------------------------------- |
Last updated:
You've read 0 of your 10 free revision notes
Unlock more, it's free!
Did this page help you?