human
Find Sum of Series 1 ^ 2 | Function to find sum of series.
If n is even.
If n is odd.
return the result.
Driver Code.
Get n.
Find the sum.
Get n.
Find the sum"
How can the above be solved in Python?
assistant
#Here is code to find Sum of Series 1 ^ 2 and the other steps required.
 def sum_of_series ( n ) :
	result = 0
	if ( n % 2 == 0 ) :
		result = - ( n * ( n + 1 ) ) // 2
	else :
		result = ( n * ( n + 1 ) ) // 2
	return result
if __name__ == " _ _ main _ _ " :
	n = 3
	print ( sum_of_series ( n ) )
	n = 10
	print ( sum_of_series ( n ) )