±«Óătv

Procedural programming

Programming that use the procedural paradigm are made up of a series of intended to be run one after another.

These procedures are made up of including variable , (IF), (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

When run, this program will output: 0 2 4 6 8