Learn various methods to print prime numbers from 1 to n in Python, such as basic iteration, sieve of Eratosthenes, and sympy library. See examples, explanations, and output screenshots for each method. Learn how to write a Python program to check if a number is prime or not using four different methods. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself. For individuals that are learning how to print prime numbers in Python, your first step is to develop a Python function that determines whether a number is prime or not. This tutorial will teach you how to write a Python program to check if a number is prime or not, both O (n) and O (√n) algorithms.