Question: Python A simple definition of scope is: 'Scope is the set of program instructions over which a variable exists, i.e. can be referred to.' 1.
Python
A simple definition of scope is: 'Scope is the set of program instructions over which a variable exists, i.e. can be referred to.'
1. Write a function named getValue, that will get an integer value from the user and save it in a variable called number. Then your function should use number to output the value.
2. Use the following main function print number. You will get an error. What causes this error? How does scope apply to this situation?
def main ():
print (number)
main()
3. Rewrite getValue() and main() so that it the value of number is accessible in main.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
