Skip to content

Instantly share code, notes, and snippets.

@karolosk
Last active February 22, 2024 18:17
Show Gist options
  • Save karolosk/de5c6421ecad41d19e04e40f2541e7c4 to your computer and use it in GitHub Desktop.
Save karolosk/de5c6421ecad41d19e04e40f2541e7c4 to your computer and use it in GitHub Desktop.
a = 3
b = 4
c = 5
if a % 2 == 0:
print(f'{a} is even')
else:
print(f'{a} is odd')
if b % 2 == 0:
print(f'{b} is even')
else:
print(f'{b} is odd')
if c % 2 == 0:
print(f'{c} is even')
else:
print(f'{c} is odd')
@karolosk
Copy link
Author

Let's assume we have some variables (a, b, and c) and we need to check if those are even numbers.
This is an example on how we may do it without using functions.
Refactor the above by using functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment