Header Ads

Responsive Ads Here

Question/Answer - 5

Question



# start -  1
# end  - 11

# 1 + 3 + 5 + 7 + 9 + 11  = 36

# Add odd number between the number entered by user(including those
numbers)


Answer



start_num = int(input("Enter the starting number: "))
end_num = int(input("Enter the ending number: "))

sum = 0
for i in range(start_num, end_num+1):
    if i % 2 == 1:
        sum += i

print(sum) 

Powered by Blogger.