What's the difference between a local and a global variable?

A global variable can be accessed from anywhere within the program whereas a local one can only be accessed from within the method it's declared in.

Answered by James H. Python tutor

1075 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a cycle "if" and "while"?


Give a segment of python code that will print the numbers 1 to 7, each one on a new line


Write a program that can convert between celcius and farenheit temperature scales


What are recursive functions and when should they be used?


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy