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.

JH
Answered by James H. Python tutor

1651 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


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 .


How do I define a function in Python?


Demonstrate a recursive solution to calculate the factorial of a number


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences