Computer Science, asked by Answer00, 11 months ago

write a program to input a number and print the sum of digits, sum of even and sum of odd digits in python​

Answers

Answered by dibyendu16
5

Answer:

#Python program to calculate sum of odd and even numbers using for loop

max=int(input("please enter the maximum value: "))

even_Sum=0

odd_Sum=0

for num in range(1,max+1):

if (num%2==0):

even_Sum=even_Sum+num

else:

odd_Sum=odd_Sum+num

print("The sum of Even numbers 1 to {0} = {1}".format(num,even_Sum))

print("The sum of odd numbers 1 to {0} = {1}".format(num,odd_Sum))

case 1

.

please enter the maximum value: 10

The sum of Even numbers 1 to 10 = 30

The sum of odd numbers 1 to 10 = 25

case 2.

please enter the maximum value: 100

The sum of Even numbers 1 to 100 = 2550

The sum of odd numbers 1 to 100 = 2500

Explanation:

hope you understand please mark me as brainliest...

Similar questions