Created
June 12, 2012 04:06
-
-
Save itsjohncs/2914854 to your computer and use it in GitHub Desktop.
Terrible Code Snippet #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_even(num): | |
"Returns true iff num is even." | |
i = 0 | |
while i < num: | |
i += 2 | |
return i == num | |
def get_even_numbers(a, b): | |
"Get all the even numbers between a and b inclusive." | |
result = [] | |
for i in range(a, b + 1): | |
if is_even(i): | |
result.append(i) | |
return result | |
# Testing | |
print get_even_numbers(5, 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment