In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 2nd
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #04 exercise sheet]


In this problem you should submit a function as described. Inside the function do not print anything that was not asked!

[IP028] And may the odds...

Happy Number Games! And may the odds be EVER in your favor...

The Problem

Write a function sum_all_odds(a, b) that given two integers a and b, returns the sum of all odd numbers from a to b (including both a and b).

Constraints

The following limits are guaranteed in all the test cases that will be given to your program:

-1000 ≤ a, b ≤ 1000       Both integers can be negative, zero, or positive

Note that is it not guaranteed that ab so your function should be adjusted accordingly.

Example Function Calls Example Output
print(sum_all_odds(5, 20))
print(sum_all_odds(20, 5))
print(sum_all_odds(20, 21))
print(sum_all_odds(-40, -70))
96
96
21
-825

Introduction to Programming (CC1024)
DCC/FCUP - University of Porto