Hello Every one !
Welcome
to devvrat knmowledgevilla
 
You are watching, Python Programming
Level 1 for beginners
Hindi Video series
Today, I will teach you, Return Statements
Before Today, We learned Function
and we seen
Function declaration,  Function definition
and function calling
if you are still remain to watch that video,
you can watch it by clicking i button at top right corner.
Let's Start !
"Return Statements"
How to declare a function ?,
How to define a function?,
that we already learned.
once again create a function
and write cube is a function name
and take "d" as arguments.
 
 
 
 
we want to calculate cube of "d",
for that Write d*d*d
 
 
It means cube of "d".
Let see
How to call this function
we will right
"cube(d)"
It means, Suppose I want to calculate cube of "3"
then i will write "cube(3)"
Let's see, will it run or not ?
we will run return statements file
Look !
There is an error
 
It's invalid syntax
i will write
":"
let's see ! once again
Now, There is no error
but
There is no output
why ?
because i called function
but forgot  to print value of it
so let it print
and run the code once again,
 
but still there is "None" Output
Why ?
Because,
We declares "cube(d)" function
we defined it
by "d*d*d"
it means
here we have taken value "3".
It calculates cube of "3",
but we didn't received answer
that's why, there is need to write,
Return Statement
Now run the code once again
and we got the output
"27", as answer
So my dear friends, we have to write return statements like this
one more thing, we can do
that is, what ever answers we are getting here
so
we can take one variable for answer
and we can store our answer on that variable "ans"
we can write
"ans = cube(3)
and
 
we will print "ans"
 
look !  what's happen
yes
we can do like this
one more thing
we can do
that is
if i will enter value of "d" earlier
i will store valu of "d" here
" d = input()
"Enter
"Enter value
"Enter value of d "
is it ok ?
 
Let see !
write here " print(cube(d))"
Look !
What's happen !
Enter value of d : "3"
but, i got an error here
TypeError is
can't multiply sequence by non-int of type 'str'
It means
value of "d" that i entered
which was stored in string
so there is need to choose data type
let's take a data type
float
now look what's happen
again
it's asked value of "d"
now i am entering value of "d" = "3"
Yes ! My friends
i got my answer "27.0"
that's it
let see by changing the value once
in place of "3" write "3.3"
and check
now it's a cube of it, that is "35.937"
so
like this we can use return statements with functions
Subscribe ! and press bell icon
Subscribe ! and press bell icon
i will teach you if statements in next video
stay connected with "devvrat knowledgevilla" thanks!
