Created
February 22, 2020 17:42
-
-
Save dpoulopoulos/39b1c1a4cdf8a134e5d1b3cef3b3abf7 to your computer and use it in GitHub Desktop.
Convenient functions to calculate prime, odd and even numbers.
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 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