Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ask the user for a number and determine whether the number is prime or not. (For those who have
- # forgotten, a prime number is a number that has no divisors.). You can (and should!) use your
- # answer to Exercise 4 to help you. Take this opportunity to practice using functions, described below.
- num = int(input("Please enter a number to test for primality: "))
- def primecheck(int):
- list = range(2, int)
- output = [x for x in list if int % x == 0]
- if not output:
- print("Your number is a prime!")
- else:
- print("Your number is not a prime!")
- primecheck(num)
Add Comment
Please, Sign In to add comment