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

Elements of A Programming Language

The five core programming elements are input/output (getting data in and out), looping and conditionals (testing conditions and repeating steps), mathematical operations, variables and data structures (storing information), and procedures and functions (making code shorter and simpler); these elements are present in almost every program and include getting input, performing calculations, storing values in variables, and organizing code into reusable procedures and functions. The document then provides more details about each element including examples of different types of loops, conditionals, variables, arithmetic operations, and how procedures and functions can help structure code.

Uploaded by

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

Elements of A Programming Language

The five core programming elements are input/output (getting data in and out), looping and conditionals (testing conditions and repeating steps), mathematical operations, variables and data structures (storing information), and procedures and functions (making code shorter and simpler); these elements are present in almost every program and include getting input, performing calculations, storing values in variables, and organizing code into reusable procedures and functions. The document then provides more details about each element including examples of different types of loops, conditionals, variables, arithmetic operations, and how procedures and functions can help structure code.

Uploaded by

Maximiliano
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Basic Programming

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:

Let's look at an ATM. You walk or


drive up to it, swipe your ATM card,
tell it how much money you want,
and, after chugging for a moment or
two, it spits out cash and a receipt. In
this simple example, we have input,
arithmetic, and output. Below is a
simple flowchart for getting $40 in
'Fast Cash' from a teller machine. 
Looping, Conditionals, and Variables
When we get to the meat of the processing, we will need looping, conditionals, and
variables to perform the task. Quite often, your program has to repeat an operation a
number of times before the program can continue (Loop).

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

Counter-controlled loops repeat the same


steps a specific number of times, regardless
of the outcome. 
A count-controlled loop is so called
because it uses a counter to keep track of
how many times the algorithm has iterated.
condition-
controlled
But a condition-controlled loop will
keep repeating the steps over and
over … and over … and over … and
over, until it gets a specific result. 
A condition-controlled loop is so
called because iteration continues
while, or until, a condition is met.
Conditionals: conditionals specify
the execution of the statements
depending on the whether
Conditionals condition is satisfied or not.
Basically it refers to an action that
only fulfills when the applied
condition on instructions is
satisfied. They are one of the most
important components of the
programming language because
they give freedom to the program
to act differently every time when
it executes that depends on input
to the instructions.
Sometimes we need computers to remember the
information we give it and that it calculates
during programs. A variable can be thought of
as a box that the computer can use to store a
Variables value. The value held in that box can change or
‘vary’. A program can use as many variables as
it needs it to.
All variables are made up of three parts:
• a name
• a type
• a value
Why use variables?
Variables are extremely useful when
programming. If a variable is used for the
length of a side in a simple program to calculate
the perimeter of a square, it is easy to calculate
the perimeter of a different sized square, simply
by changing the value of the variable.
Data Types
The most Basic data types are:
• Strings- used to hold text or
numbers that will not be used
for calculations
• Integers- whole numbers
• Float- numbers that use
decimal points
• Boolean- used for logic to hold
true or false options
When writing programs, we should avoid long,
repetitive code. Procedures and functions help to
keep our programs simple and short. 

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. 

You might also like