Q. Consider the following code and write the flow of execution for this. Line numbers have been given for your reference.

def power (b, p):            # 1
    y = b ** p               # 2
    return y                 # 3
                             # 4
def calcSquare(x):           # 5
    a = power (x, 2)         # 6
    return a                 # 7
                             # 8
n = 5                        # 9
result = calcSquare(n)       # 10
print (result)               # 11

Answer :-

1->5->9->10->5->6->1->2->3->6->7->10->11

Output :-

25
>>> 

16 Comments

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

  1. the answer is not very clear

    ReplyDelete
    Replies
    1. At first you have to study about flow of execution then you will able to understand.

      Delete
  2. The answer is clearly wrong, we also have to go the 1st function after entering 5 and then after 6 it should be 1 again, the answer is wrong update it

    ReplyDelete
  3. Dark Phoenix :)2 July 2022 at 12:14

    Really appreciate it :)

    ReplyDelete
  4. After 6 it will directly go to 7

    ReplyDelete
  5. Can you explain the reason behind the flow and why it is going on line 1 after 6

    ReplyDelete

Post a Comment

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

Previous Post Next Post