Programming concepts (3)

Resources | Revision Questions | Computer Science

Login to see all questions

Click on a question to view the answer

1.

Explain why using comments and consistent naming conventions is important when writing programs. Consider the benefits for yourself and for other programmers who may need to understand or modify the code later.

2.

Consider the following Python code:

  x = 10  # Global variable

  def my_function():
    x = 5  # Local variable
    print("Inside function: x =", x)

  my_function()
  print("Outside function: x =", x)
  

What output will this code produce? Explain why.

3.

Define the terms 'procedure' and 'function' in the context of computer programming. Explain the key difference between them.