Docsity

Programming: Library Routines, Procedures & Functions - A Comprehensive Guide, Schemes and Mind Maps of Computer science

Partial preview of the text

Download Programming: Library Routines, Procedures & Functions - A Comprehensive Guide and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Programming

Library Routines, Procedures & Functions

Built in Functions Many programming languages will use built in functions ready to be used. What built in functions can you remember for Python? bin, chr, float, int, max, min, ord, len, round When thinking about the difference between Functions and Procedures, what do all of the above have in common? They all return a value

Library Routines So what are Library Routines? How are they different? A tested and ready to use routine available in the development system of a programming language that can be incorporated into a program What examples can you think of that we have used in Python? print, input (have a little cross over with functions) - Standard Library Routines Math, random, time - Libraries that we can pull into our code if we require them

Library Routines - Pseudocode

Procedures in Pseudocode (no parameters)

PROCEDURE

<statement(s)>

ENDPROCEDURE

TO RUN

CALL

Procedures in Pseudocode (parameters) PROCEDURE( : , : ...) <statement(s)> ENDPROCEDURE TO RUN CALL (Value1, Value2, ...)

Functions in Pseudocode (no parameters)

FUNCTION RETURNS

<statement(s)>

RETURN

ENDFUNCTION

TO RUN

OUTPUT identifier()

Functions in Pseudocode (parameters) FUNCTION ( : , : ,...)RETURNS <statement(s)> RETURN ENDFUNCTION TO RUN OUTPUT identifier (param1, param2)

Function Pseudocode Task 2 Write a Function using Pseudocode that returns the sum of an array of numbers Your function should take one parameter (array of numbers) and return an integer. Your function should add all of the numbers in the array together and return the value. Call your function 5 times with different values each time.

Keywords Complete the Programming Keywords on Google Classroom This needs to be completed for homework if not done this lesson