Total=0;
def sum(arg1,arg2):
total=arg1+arg2;
print("total:",total)
return Total;
sum(10,20);
print("total:",total)
Answers
Answered by
4
Language:
Python
Progam:
Total=0;
def sum(arg1,arg2):
total=arg1+arg2
print("total:",total)
return Total
sum(10,20)
print("total:",total)
Output:
Errors.
Local variable Total not defined.
Corrected prorgam:
total=0;
def sum(arg1,arg2):
total=arg1+arg2
print("total:",total)
return total
sum(10,20)
print("total:",total)
New Output:
total:30
30
Explanation:
A local variable is defined within a function. It has no reach outside the fucntion.
A global function is accessible throughout the fucntion.
Similar questions
Math,
2 months ago
English,
2 months ago
English,
2 months ago
Political Science,
3 months ago
Math,
3 months ago