What is the logic to check if a number is prime or not in python?

0 votes
I am looking for a function with conditional and control statements for the same logic.
Aug 2, 2019 in Python by Waseem
• 4,540 points
111 views

1 answer to this question.

0 votes

n = int (input ('ENTER NUMBER TO CHECK WETHER ITS PRIME OR NOT \n'))

for i in range (2 , n):

if n % i == 0 :

print ('_NOT_ PRIME NUMBER')

break

else :

print ('IT\'s PRIME NUMBER')
answered Jul 16 by amrut
• 240 points

Related Questions In Python

0 votes
2 answers

Check a number is Prime or not in Python

There is an efficient way to write ...READ MORE

answered Oct 26, 2018 in Python by Priyaj
• 57,700 points
908 views
0 votes
1 answer

What is the Python logic to count the number of capital letters in a file?

Hi, You can use this piece of code, ...READ MORE

answered Jun 26 in Python by Roshni
• 4,810 points
106 views
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

answered Feb 12, 2019 in Python by Nymeria
• 3,520 points
5,188 views
0 votes
1 answer

How to check if a float value(decimal number) is between range(0 to 10) in python

Hello,  A function that returns True for an integer number (int or ...READ MORE

answered Sep 13 in Python by Niroj
• 68,560 points
453 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,476 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,800 points
1,108 views
0 votes
2 answers

What is the python logic to check if a number is armstrong number or not?

a = int (input('enter number')) num = a sum ...READ MORE

answered Jul 16 in Python by amrut
• 240 points
115 views
+1 vote
2 answers

how can i do a binary search in python?

def Binary_search (array , element):       ...READ MORE

answered Jul 10 in Python by anonymous
• 240 points
103 views