Computer Science, asked by Anonymous, 11 months ago

Write a python script to find all prime and composite numbers till 100 separately.

Answers

Answered by AbhijithPrakash
3

'''

Hi, I'm Abhijith Prakash.

Here is your code...

'''

print ("All Prime Numbers till 100 are as followed:")

# Code for the Prime Numbers till 100.

def is_prime(x):

 prime = True

 for i in range(2,x):

   if ((x%i) == 0):

     prime = False

 return prime

# Creator "_Abhijith Prakash_"

if __name__ == '__main__':

 count = 0;

 number = 2;

 while (count<25):

   if (is_prime(number)):

     print(number)

     count = count+1

   number = number+1

print (" ")

print (" ")

# Creator "_Abhijith Prakash_"

print ("AND")

print (" ")

print (" ")

print ("All Composite Numbers till 100 are as Followed:")

# Code for the Composite Numbers till 100.

def is_prime(x):

 prime = False

 for i in range(2,x):

   if ((x%i) == 0):

     prime = True

 return prime

if __name__ == '__main__':

 count = 0;

 number = 2;

 while (count<74):

   if (is_prime(number)):

     print(number)

     count = count+1

   number = number+1

Attachments:

Anonymous: Thank you!!
AbhijithPrakash: WELCOME :)
Similar questions