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
What about the other lines #5 #6 #7 ?
ReplyDeleteIt is written.
Deletewhere is flow of execution for Q6
ReplyDeleteIt is written.
DeleteIs this a non void function??
ReplyDeleteYes.
DeleteWhere is function 8
ReplyDeleteWhich one ??
DeleteThe 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
ReplyDeletePlease see previous questions.
DeleteWhere is fun(8), which is in question?
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )