Choose exam board for KS4 Computer Science (GCSE)
Choose exam board for KS4 English
Choose exam board for KS4 French
Choose exam board for KS4 Geography
Choose exam board for KS4 German
Choose exam board for KS4 History
Choose tier for KS4 Maths
Choose exam board for KS4 Music
Choose exam board for KS4 Physical education (GCSE)
Choose exam board for KS4 Religious education (GCSE)
Choose exam board for KS4 Spanish

      Good programming practices

      Lesson details

      Learning outcome

      I can explain what is meant by good programming practices and adopt these practices when writing my own code.

      Key learning points

      1. Good programming practice involves taking steps to make your code easier to read and understand.
      2. Variables should always have meaningful identifiers so that the reader of the code understands how they are used.
      3. Comments are used in programs to help make it easier for a programmer to understand what it does.

      Keywords

      • Comment - text within source code that is ignored by the compiler or interpreter, used to help programmers understand the code

      • Identifier - the name that a programmer gives to a variable, constant, or subroutine

      • Maintainability - refers to the ease with which maintenance activities can be performed on code, such as correcting errors

      Common misconception

      Comments are added to code to help you understand your program.

      Comments are used to make the code more readable to a programmer who seeks to understand it. The comments should be written in a style that would help them make sense of the program.

      Teacher tip

      To extend this lesson, you could get a sample of pupils' code and ask them to annotate the code to identify good and poor practices.

      Equipment

      Pupils will need access to a device that can edit and run Python programs. Examples in this lesson use the RPF Code Editor https://oak.link/python-editor

      Licence

      This content is © Oak National Academy Limited (2026), licensed on Open Government Licence version 3.0
      except where otherwise stated. See Oak's terms & conditions
      (Collection 2).

      Lesson video

      Loading...

      Prior knowledge starter quiz

      6 Questions

      Q1.
      Match the Python function to its purpose

      Correct Answer:`input()`,takes user input

      takes user input

      Correct Answer:`int()`,converts a string to an integer

      converts a string to an integer

      Correct Answer:`lower()`,converts text to lowercase

      converts text to lowercase

      Correct Answer:`print()`,displays output on the screen

      displays output on the screen

      Q2.
      selection in programming is a selection statement placed inside another selection statement.

      Correct Answer: Nested, ested

      Q3.
      What does the upper() method do when used on a string in Python?

      Correct answer: converts all letters to uppercase
      converts all letters to lowercase
      checks if the string contains numbers
      removes spaces from the string

      Q4.
      How can a program be modified to check more than one username?

      use multiple elif statements
      store all usernames in a list and check using if username is in list
      use a loop to ask for different usernames
      Correct answer: all of the above

      Q5.
      The correct way to ensure case-insensitive username input is: `username = input().`

      Correct Answer: lower(), lower, upper(), upper

      Q6.
      The expression if score > 10: checks if the score is __________ 10.

      less than
      greater than or equal to
      Correct answer: greater than
      equal to

      6 Questions

      Q1.
      Why are good programming practices important?

      They make the code run faster.
      Correct answer: They make the code easier to read and maintain.
      They reduce the number of lines in a program.
      They allow variables to store more data.

      Q2.
      What is the purpose of comments in programming?

      to increase the execution speed of a program
      to make the program output messages to the user
      Correct answer: to explain parts of the code to programmers
      to create variables

      Q3.
      What is snake case, and where is it commonly used?

      a type of loop in Python
      Correct answer: a naming convention where words are separated by underscores (_)
      a function for checking errors in Python
      a built-in Python module

      Q4.
      To make a program easier to understand, you should use variable names instead of single-letter names like x or y.

      Correct Answer: meaningful, eaningful

      Q5.
      Match the good programming practice with its purpose.

      Correct Answer:comments,explains parts of the code to other programmers

      explains parts of the code to other programmers

      Correct Answer:program layout,uses indentation and spacing to improve readability

      uses indentation and spacing to improve readability

      Correct Answer:identifiers,meaningful variable names to describe stored data

      meaningful variable names to describe stored data

      Correct Answer:naming conventions,follow standard ways of writing variable names

      follow standard ways of writing variable names

      Q6.
      is the ease with which maintenance activities can be performed on a program, such as fixing errors.

      Correct Answer: Maintainability

      To help you plan your 10 computer science lesson on: Good programming practices, download all teaching resources for free and adapt to suit your pupils' needs...