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

Related Python Mentoring answers

All answers ▸

Write a function that takes an imput (call it usr_in), the user's age (usr_age) and the user's name (usr_nm) and outputs the following string: "Hi, My name is [usr_nm], I am [usr_age] years old, and my favorite number is [usr_in]"


Which function is ran when an object is instantiated?


Write a recursive function that takes any integer n and prints the nth Fibonacci number.


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