Home News Sport Earth Reel Worklife
Home Learn Study support Careers My Bitesize More
KS3
Programming basics
Arithmetic
Programming is writing computer code to create a
program, in order to solve a problem. To program a
computer, you need to know how programs are
constructed.
Part of Computer Science Programming
Save to My Bitesize
Revise Test
Pages
Arithmetic
Variables
Naming variables
Working with variables
Input and output
Arithmetic
Programming is writing computer code to create a program, to solve a
problem. Programs are created to implement algorithms . Algorithms
can be represented as pseudocode or a flowchart , and programming is
the translation of these into a computer program.
To tell a computer to do something, a program must be written to tell it
exactly what to do and how to do it. In order to do this, you need to know how
programs are constructed.
Basic arithmetic
Arithmetic is used all the time in computer programs, so an understanding of
how computers use arithmetic is useful. This table lists the common
arithmetic processes with their programming equivalents:
Arithmetic process Programming equivalent
Addition (plus) +
Arithmetic process Programming equivalent
Subtraction (minus) -
Multiplication *
Division /
Computers can be programmed to carry out calculations – so long as the
correct formulas to use are known. Some simple mathematical examples in
Python (3.x) are:
>>> print(5 + 7)
12
>>> print(7 - 5)
2
>>> print(5 * 7)
35
>>> print(35 / 7)
5.0
More complicated calculations can be performed too:
>>> print((5 * 2) + (4 - 3))
11
>>> print((8 / 4) + (2 - 1))
3.0
Next page
Variables
More guides on this topic
Introduction to programming Selection in programming
Iteration in programming Boolean logic Arrays and lists
Procedures and functions Writing error-free code
Related links
Jobs that use Computer Science BBC Click BBC Technology news
Tech Tent Headsqueeze Khan Academy Raspberry Pi
Language:
English
Code Club Subscription Educational App Store Subscription
Home Earth Travel Music Sounds
News Reel Culture TV
Sport Worklife Future Weather
Terms of Use About the BBC Privacy Policy Cookies Accessibility Help Parental Guidance
Contact the BBC Get Personalised Newsletters Why you can trust the BBC Advertise with us
Do not share or sell my info
© 2024 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external
linking.