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

1609 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Create an algorithm that can be used as a guessing game. Make sure to import random at the start.


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


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


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:


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