human
What is a code to calculate square of a number without using * , / and pow ( ) and the other steps required given the following:
Calculate square of a number without using * , / and pow ( ) | Simple solution to calculate square without using * and pow ( ).
handle negative input.
Initialize result.
Add n to res n - 1 times.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to calculate square of a number without using * , / and pow ( ) and the other steps required.
 def square ( n ) :
	if ( n < 0 ) :
		n = - n
	res = n
	for i in range ( 1 , n ) :
		res += n
	return res
for n in range ( 1 , 6 ) :
	print ( " n ▁ = " , n , end = " , ▁ " )
	print ( " n ^ 2 ▁ = " , square ( n ) )