Programming procedural languagesLanguage used by a programmer to write piece of software that use the procedural paradigm are made up of a series of procedureA section of computer code that performs a specific task. intended to be run one after another.
These procedures are made up of statementThe smallest element of a programming language which expresses an action to be carried out. including variable assignmentSetting the value of a variable in a computer program., selectionA decision within a computer program when the program decides to move on based on the results of an event. (IF), iterationIn computer programming, this is a single pass through a set of instructions. (loops) and procedures.
Modularity (each part of the code is self-contained and reusable) is introduced through procedures, from which the paradigm gets its name.
For example, a procedure to output even numbers between 0 and a number entered by a user:
def countEven(n): #define a procedure called countEven
for i in range (0, n): #an iteration (loop)
if i % 2 == 0: #Selection. If count variable Modulus 2=0, print counter
print(i)
i += 1 #count variable is incremented
countEven(10) #Procedure call