Turn on thread page Beta
    • Thread Starter
    Offline

    20
    ReputationRep:
    Our teacher is telling us to use it for the coursework but i dotn understand what the function of global ( name) is?
    Offline

    18
    ReputationRep:
    Really? My teacher said that using global variable makes you loose marks.

    A global variable is essentially a variable that is accessible throughout the program (not just in one variable).
    Offline

    19
    ReputationRep:
    Generally most people say not to use global variables but depending on the task, they may be more efficient.

    Local variable is something that only is accessible in one function. While global can be used through out. So

    a = "hello"
    Def example():
    b = "world"
    Print(a)
    Print(b)

    Def example2():
    Print(a)
    Print(b)

    Run example() and result will be "hello" "world"
    Run example2() and you'll get "hello" and then an error for non existent variable because it's only available in example()
 
 
 

3,443

students online now

800,000+

Exam discussions

Find your exam discussion here

Poll
Should universities take a stronger line on drugs?
Useful resources

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.