Skip to content

Instantly share code, notes, and snippets.

@timeowilliams
Created September 18, 2020 16:10
Show Gist options
  • Save timeowilliams/a45fed7c5a864fedce5a99a0d7d4e359 to your computer and use it in GitHub Desktop.
Save timeowilliams/a45fed7c5a864fedce5a99a0d7d4e359 to your computer and use it in GitHub Desktop.
Practice Python 11: Is it Prime?
#In this program, I've created the function isPrime(), which allows the user to call the function,
#enter a number, and then immediately see if it is or isn't a prime number.
def isPrime(x):
for i in range(2,x):
if x % i == 0:
test = True
else:
test = False
if test is True:
print('This is not a prime number')
else:
print('This is a prime number')
#Test cases:
#1. 67
#Enter a number: 67
#This is a prime number
#2. 100800000
#Enter a number: 10800000
#This is a prime number
#3: 4237
#>>> isPrime(4237) - First use case of the function, isPrime
#This is a prime number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment