Computer Science, asked by 2305438, 3 months ago

Total=0;
def sum(arg1,arg2):
total=arg1+arg2;
print("total:",total)
return Total;
sum(10,20);
print("total:",total)

Answers

Answered by allysia
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