A Level Computer Science OCR Test 2025 – 400 Free Practice Questions to Pass the Exam

Question: 1 / 400

What can a global variable in Python be declared with?

Static keyword

Global keyword

A global variable in Python can be declared using the global keyword. This keyword allows you to define a variable within a function or block of code that refers to a variable defined outside that function or block, specifically in the global scope. This means the variable can be accessed and modified throughout the entire program, which is particularly useful for sharing data across different functions.

When the global keyword is used inside a function, it tells Python that you are referring to the globally scoped variable, rather than creating a new variable that is local to the function. This helps maintain a clear distinction between local and global variables, providing better control over how data is accessed and manipulated within your program.

The other options refer to concepts or keywords that do not apply to the declaration of global variables in Python. Static is more commonly associated with statically typed languages, instance relates to object-oriented programming and the scope of variables within class instances, and const is not a keyword used in Python for defining constants or variables.

Get further explanation with Examzify DeepDiveBeta

Instance keyword

Const keyword

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy