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

1588 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a for loop and a while loop.


Make a program that asks the user for a series of numbers until they either want to output the average or quit the program.


Sales is real Customers is integer startmainprog input Sales input Customers if ((Sales > 500) OR ((Sales > 300) AND (Customers>9))) then output “Bonus Awarded” else output “No Bonus” end if end subroutine. Sales = 600 Customers = 9, answer:


What are the main data structures that I can use in Python


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