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

1551 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Give an example of a FOR loop


Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are: (a) even numbers, and (b) from elements in the original list that had even indices .


Write a recursive function to find the factorial of a number n.


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


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–2025

Terms & Conditions|Privacy Policy
Cookie Preferences