Elements of A Programming Language
Elements of A Programming Language
Elements
Five Basic Programming Elements
Programming is somewhat like working with building blocks. Given enough children's toy
blocks, you can build just about anything with only a few kinds of blocks.
There are five core components of a computer program that are present in almost every program.
The five basic elements, in programming are:
• Input/output: getting data and commands into the computer/getting your results out of the
computer
• Looping and conditionals: testing to see if a condition is true of false, and cycling through a
set of instructions until some condition is met
• Mathematical operations (arithmetic): Performing mathematical calculations on your data
• Variables and data structures: storing information, which may change over time
• Procedures and Functions: can make code shorter, simpler and easier to write.
Input can come from just
about anywhere: a keyboard,
Input a touchscreen, a text file, and
another program are just a
few examples. Input is one of
the two elements that are
used by every program
because every program needs
some data to work with.
Output
Output is the result that your program
gives you. That is the whole purpose of
writing a program: to ask a question and
get the answer! Output can take many
forms - text or graphics, either printed or
on a screen, a sound - just about any
form that can be interpreted and
understood by a human being or another
program.
Arithmetic
Computers can perform all kinds of mathematical operations and
functions, from the simple addition or subtraction, to the complex
calculus needed to put a satellite into orbit. Not every program needs to
do calculations on the data that's entered, but it may still need to do some
in order to control what is happening inside the program itself.
This table lists the common arithmetic processes with their programming
equivalents:
Example:
Loops
There are a number of different types of loops which are used, based on how the input or
calculations need to be handled. All of them are either condition-controlled or counter-
controlled. The control part is important - if there is no control, the loop can go on
forever (or until you stop the program).
Counter-
controlled
Procedures Challenge 5:
and functions
For Challenge number 5 deliver a written report
or research about Procedures and functions,
definition and how to create procedures
and functions in python. Deliver this alongside
your pseudocodes and flowcharts of the
mentioned levels of challenge 5 in canvas.