while running the both programs ,not any output i am getting .
pls help
That is because nowhere in your code was the function called. To call the function properly, deindent the line:
area(4)
YOur code should look something like this:
def area(l):
***a = l * l
***print(“Area is:”, a)
area(2)
The leading asterisks represents spaces used for indenting the function body.
What you have done here intentionally or unintentionally is recursion which does not seem to achieve the goal. So, the ideal way would be to push the last line to the left end so that the function is called correctly and it will give you the correct output.
The correct code for the given program is
def area(l):
a=l*l
print(“Area is:”,a)
area(2)
The problem in your code was that you didnt follow the indentation properly.In your code the line area(2) is also included within the function definition
The error is because of the indentation is not properly followed. just remove the indentation at line 4 and the program compiles and runs successfully.