HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Notes
  2. /Procedures, Functions and Strings: Quick Revision
Computer ScienceAlso Python Programming

Procedures, Functions and Strings: Quick Revision

A brief note on procedures, functions and strings in Cambridge pseudocode: parameters, local and global variables, the library routines, string handling and maintainable programs, with the usual slips. With practice, a program and questions to check yourself.

StemPy LabWritten by StemPy Lab
Log in to save

A brief note on Procedures, Functions and Strings. Read it before a test. Try each question at the end before you open its answer.

Subroutines

  • Procedure: PROCEDURE Name(Param : TYPE) ... ENDPROCEDURE. Run it with CALL Name(value).
  • Function: FUNCTION Name(Param : TYPE) RETURNS TYPE ... RETURN value ... ENDFUNCTION. Use it inside an expression, never with CALL.
  • Parameters: at most three, each with a data type. Arguments match them in order.
  • Local variable: declared inside a subroutine, used only there. Global variable: declared in the main program, used anywhere.
  • Subroutines are defined at the start of the code.

Library routines

  • DIV(A, B): the whole part. MOD(A, B): the remainder.
  • ROUND(Value, Places): rounds to that many decimal places.
  • RANDOM(): a number from 0 to 1, both included. ROUND(RANDOM() * 6, 0) is a whole number from 0 to 6.

Strings

  • LENGTH(Text): the number of characters, spaces included.
  • SUBSTRING(Text, Start, Length): usually position 1 is the first character.
  • UCASE and LCASE: upper and lower case.
  • A loop over a string: FOR I ← 1 TO LENGTH(Text) with SUBSTRING(Text, I, 1).

Maintainable programs

  • Meaningful identifiers, comments, constants and subroutines.
  • In the 15-mark scenario: list the tasks, plan the data, write in commented parts, dry-run it.

Practice with new numbers

A program to try

The program defines a function that counts the words of a sentence by counting its spaces, the way a pseudocode loop with SUBSTRING would.

Read it first. Then run it. Is the word count right?

1. Put two spaces between two words. What goes wrong, and how could you check for it?

Mistakes to avoid

  • CALL with a function, or a function with no RETURN.
  • A local variable used outside its subroutine.
  • Counting string positions from 0 when the question uses 1.
  • Forgetting the spaces in LENGTH.
  • Magic numbers where a constant belongs.

Check yourself

  1. What does SUBSTRING("Rainbow", 5, 3) return?
  1. Can a procedure return a value?
  1. What does ROUND(9.96, 1) return?
  1. Write a statement that outputs the first character of City in lower case.
  1. Why use a local variable for a loop counter inside a procedure?

Sources

  • Cambridge International, IGCSE Computer Science 0478 syllabus for 2026 to 2028, unit 8.1 and section 4 (pseudocode).
← All Notes
← Variables, Selection and Loops: Quick RevisionArrays and Files: Quick Revision →
More onComputer Science › Programming

Discussion (0)

Log in to join the discussion.

Loading…

On this page

  1. Subroutines
  2. Library routines
  3. Strings
  4. Maintainable programs
  5. Practice with new numbers
  6. A program to try
  7. Mistakes to avoid
  8. Check yourself
  9. Sources

Goes with the lesson

  1. Maintainable programs and the long scenario questionProcedures, Functions and Strings in Pseudocode

More notes on this topic

  1. Arrays and Files: Quick Revision
  2. Variables, Selection and Loops: Quick Revision
  3. Logic Circuits and Truth Tables: Quick Revision
  4. NAND, NOR and XOR Gates: Quick Revision
  5. NOT, AND and OR Gates: Quick Revision
All notes on this topic →