Not getting the result of program

Hey @dhirajworked its just simple you don’t need to worry…
after the 3rd line i.e. that’s the end of the function definition so you need to call the function outside the function definition.The solution is
def area(l):
a=l*l
print(“Area is:”,a)
area(2)
hope you got the solution…have a good day

To get the correct output , function call should be outside the function body.
so ,remove the indentation for the line area(2).

Hi @dhirajworked ,
In the code you provided, the print statement is included in the function definition.
So the print statement will be executed only when the function area(l) is called.
So the code with the required edit is as follows:
image

In the above code, I have just made 1 edit, which was to call the function area(l).
Hope this solves your issue.

In your section of code, you have written area(2) inside the scope of the function itself. You can simply clear all the spaces before area(2) to get the result, & after doing so, you code will look like this:

def area(l):
  a = l*l
  print("Area is:", a)
area(2)

The correct code for the given program is
def area(l):
a=l*l
print(“Area is:”,a)
area(2)
problem in your code
that you didnt follow the indentation properly.In your code the line area(2) is also included within the function definition

hii, the code you wrote is perfect but please pay attention while calling a function. The basic requirement of creating a function is calling and executing that function whenever required. While calling the function you should call it outside the function as shown below. Please be careful about Indentation.

def area(l):
area=l*l
print(area)
area(2)

Because you have include the function calling statement inside the function itself.
It should be like:

python is a space specified language
the error is in the line 2 ,3 & 4
and thts’s why the function is calling properly.
the correct form is this:
def area(l):
a=l*l
print(“Area is:”,a)
area(2)

The problem in your code is that you have not followed the indentation properly.
The function call area(2) lies within the block of the function.
The function should be called outside the function block.

The correct code is as follows:

def area(l):
__a=l*l
__print(“Area is:”,a)
area(2)

where _ represents space.

I hope this solution helps.

https://forum.boltiot.com/t/not-getting-the-result/24643/27?u=ankita_kanchan

Above is an answer to a similiar (in fact exactly same) problem.

In your section of code, you have written area(2) inside the scope of the function itself. You can simply clear all the spaces before area(2) to get the result, & after doing so, you code will look like this:

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