An environmental scientist is doing some important work for Planet Earth.
He takes 10 pollution values from a river and performing a complicated calculation on the value:
pollutionIndex = (value+2563)/value3
dangerLevel = (polutionIndex/32.1)2
result = dangerLevel/10+pollutionIndex
He wants to store the results in an array.
He has written a little program using his rather rudimentary Python skills:
#create a global variable to store the processed data
arr = []
for i in range(10):
data = double(input("Enter a value")
#call a function,send it the data and assign the returned value to a variable
x = processValue(data)
#append the data into an array
arr.append(x)
It takes the data that is passed to it, does some calculations and returns the result!
def processValue(value):
pollutionIndex = (value+2563)/value3
dangerLevel = (pollutionIndex/32.1)2
result = dangerLevel/10+pollutionIndex
return result
This module is passed some data as a parameter from a computer program.
It processes the data!
It returns something to the computer program when it has finished.
Try writing this program if you are not sure about it. Don't copy and paste. Try to do it yourself.
A module that returns something is called a FUNCTION
module function return identifier parameter pseudocode return typedefinecalldata type