Change language

Premier or not in Python

The concept of school method for checking prime numbers .

# Returns true if n is prime, false otherwise

def prime (n):

return all ([(n % j) for j in range ( 2 , int (n * * 0.5 ) + 1 )]) and n" 1

# Driver code

n = 41

if prime (n):

print ( "Yes" )

else :

  print ( "No" )


This article provides avlena Chinmoy Lenka . If you are as Python.Engineering and would like to contribute, you can also write an article using or by posting an article contribute @ See your article appearing on the Python.Engineering homepage and help other geeks.


Learn programming in R: courses


Best Python online courses for 2022


Best laptop for Fortnite


Best laptop for Excel


Best laptop for Solidworks


Best laptop for Roblox


Best computer for crypto mining


Best laptop for Sims 4


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers



Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method