Signed up recently but had issues with the confirmation email?
Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.
Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.
Functions and Procedures: global variables
2.2.3 Additional Programming Techniques
Practise exam questionsAdditional Programming Techniques — Note 10 of 13
The use of global variables within functions and procedures:
A global variable is defined in the main program (outside any sub-program) and can be accessed from anywhere in the program, including inside functions and procedures. While useful for sharing data, overusing global variables can make programs harder to debug and maintain.
global keyword: global userID = "Cust001".global keyword inside a function to modify a global variable.global score = 0 // global variable
procedure addPoints(points)
score = score + points // changes the global
endprocedure
addPoints(10)
addPoints(5)
print(score) // 15score = 0 # Global variable
def add_points(points):
global score
score = score + points # Modifies the global
add_points(10)
add_points(5)
print(score) # Output: 15const vat = 0.2, can't be changed once it is set.Ready to test yourself?
Practise 2.2.3 questions