Skip to content

Instantly share code, notes, and snippets.

@itsjohncs
Created June 12, 2012 04:06
Show Gist options
  • Save itsjohncs/2914854 to your computer and use it in GitHub Desktop.
Save itsjohncs/2914854 to your computer and use it in GitHub Desktop.
Terrible Code Snippet #2
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