Skip to content

Instantly share code, notes, and snippets.

@dpoulopoulos
Created February 22, 2020 17:42
Show Gist options
  • Select an option

  • Save dpoulopoulos/39b1c1a4cdf8a134e5d1b3cef3b3abf7 to your computer and use it in GitHub Desktop.

Select an option

Save dpoulopoulos/39b1c1a4cdf8a134e5d1b3cef3b3abf7 to your computer and use it in GitHub Desktop.
Convenient functions to calculate prime, odd and even numbers.
def check_prime(x):
"""
Convenient function that checks if a number is prime.
"""
if x > 1:
for i in range(2, x):
if (x % i) == 0:
return False
else:
return True
else:
return False
def check_odd(x):
"""
Convenient function that checks if a number is odd.
"""
if (x % 2) == 0:
return False
return True
def check_even(x):
"""
Convenient function that checks if a number is even.
"""
if (x % 2) == 0:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment