Computer Science, asked by rexkumar7, 1 month ago

Write a Python function sumsquare(l) that takes a nonempty list of integers and returns a list [odd,even], where odd is the sum of squares all the odd numbers in l and even is the sum of squares of all the even numbers in l

Answers

Answered by VISHALKUMARV22
1

#Python Program to find Sum of Even and Odd

NumList = []

Even_Sum = 0

Odd_Sum = 0

Number = int(input("Please enter the Total Number of List Elements: "))

for i in range(1, Number + 1):

value = int(input("Please enter the Value of %d Element : " %i))

NumList.append(value)

for j in range(Number):

if(NumList[j] % 2 == 0):

Even_Sum = Even_Sum + NumList[j]

else:

Odd_Sum = Odd_Sum + NumList[j]

print("\nThe Sum of Even Numbers in this List = ", Even_Sum)

print("The Sum of Odd Numbers in this List = ", Odd_Sum)

Similar questions