Is this a prime number #
Write a function that takes a number as input and determines whether it is a prime number. A prime number is a whole number greater than 1 whose only factors are 1 and itself.
Examples:
- 2 is a prime number because 2 is divisible only by 1 and 2.
- 3 is also a prime number because it is divisible only by 1 and 3.
- 4 is not a prime number because it is divisible by 1, 2, and 4.
- 25 is not a prime number because it is divisible by 1, 5, and 25.
- 100 is not a prime number because it is divisible by 1, 2, 4, 5, 10, 20, and 50.
- 997 is a prime number because it is divisible only by 1 and 997.
Tests #
is_prime(2)should returnTrueis_prime(17)should returnTrueis_prime(97)should returnTrueis_prime(121)should returnFalseis_prime(999)should returnFalseis_prime(10007)should returnTrueis_prime(99991)should returnTrueis_prime(100003)should returnTrueis_prime(1000000)should returnFalse
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules