Question: def square ( n ) : # handle negative input if ( n < 0 ) : n = - n # Initialize result res
def squaren:
# handle negative input
if n :
n n
# Initialize result
res n
# Add n to res n times
for i in range n:
res n
return res
# Driver Code
for n in range:
printn n end
printn squaren
Can you explain the res part
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
