Not getting the result of program

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.


I hope the solution helps

def area(l):
a=l*l;
print(“Area is:”,a)
area(2)
Your code should be in this format as python is space specific so the indentation should be proper

the problem is you didn’t follow the indentation properly in you code line(4)

Hey @dhirajworked,
You have not followed the correct spacing ( indentation) in your code and also you are calling the function in the function call itself.

Function call should be outside of the function definition

A correct syntax would be :

def area(l):
___a = l * l
___print(“Area is:”, a)

area(2)

where _ is spaces

please follow indentation in your code line (4)

There may be indentation or spacing error in the program code which you have written.
def area(l):
a = l * l
print(“Area is:”, a)
area(2)
This is the correct way to write the code

The area(2) part should come out of the loop the way u did def area(l).

Hi @dhirajworked , the problem for your code is “INDENTATION”.
So, when you are calling any function defined above. You have to call the function without giving indentation.


So, I hope your issue is solved.
Thank you

The error is due to the wrong indentation in line number4 .
We can’t call the function in same function itself, we have to call it outside the function.
The correct code would be as follows:
def area(l):
___a = l * l
___print(“Area is:”, a)

area(2)

I have checked your program. The solution is simple. You have made a slight mistake with the indentation in line 4, which has caused the calling of the function area() to become a part of the function itself.
The correct code is this:
def area(l):
a=l*l
print (“Area is:”,a)
area(2)

Hope this helps.

The function must be called outside the function definition

def example_func(n):
. . . . . . . . .
. . . print(n*2)
example_func(4) # function call

You have an indentation error
just shift the last line of code to the complete left.
Cause it is not part of the function that you are defining
Last line of code is calling the function

area(2) should be outside the indentation of ‘def area()’ in line 4
def area(l):
a = l*l
print ( “Area is:”,a)
area(2)

def area(b):
***a = b * b
***print(“Area is:”, a)

area(2)

this is an indentation error please refer the above code

try writing it in the console it works then.