Q. Write a program with non-void version of above function and then write flow of execution for both the programs.

Answer :-

Non Void Version :-

def fun(x):              #1
    return (x ** 2)      #2

print (fun(4))           #3
print (fun(6))           #4
print (fun(2+1))         #5
print (fun(4-3*2))       #6
print (fun(3-2))         #7

Flow of execution :-

1 --> 3 --> 1 --> 2 --> 3 --> 4 --> 1 --> 2 --> 4 --> 5 --> 1 --> 2 --> 5 --> 6 --> 1 --> 2 --> 6 --> 7 --> 1 --> 2 --> 7


Void Version :-

def fun(x):              #1
    print (x ** 2)       #2

fun(4)                   #3
fun(6)                   #4
fun(2+1)                 #5
fun(4-3*2)               #6
fun(3-2)                 #7

Flow of execution :-

1 --> 3 --> 1 --> 2 --> 4 --> 1 --> 2 --> 5 --> 1 --> 2 --> 6 --> 1 --> 2 -->  7 --> 1 --> 2


11 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. What about the other lines #5 #6 #7 ?

    ReplyDelete
  2. where is flow of execution for Q6

    ReplyDelete
  3. Is this a non void function??

    ReplyDelete
  4. Where is function 8

    ReplyDelete
  5. The question asks for the following number of the given number not its square, the function that is given is giving the value of the given numbers square

    ReplyDelete
  6. Where is fun(8), which is in question?

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post