Write Python Script Test Whether Following Numbers Prime Using 101primetxt File 2692493 26 Q37099464

Write a Python script to test whether the following numbers areprime using the 101prime.txt file.

2692493

2692503

4632703

8767843

7982119

7983121

13065521

11505341

11505343

14123649

14123651


Solution


2692493 4632703 7983121 11505341 11505343 mport math # reading file f-open(101prime.txt).read().split() # considering each

import math

# reading file

f = open(“101prime.txt”).read().split()

# considering each number

for one in f:

n = int(one)

# checking if it is prime

isPrime = True

for i in range(2, int(math.sqrt(n))+1):

if n%i == 0:

isPrime = False

break

# printing if it is primme

if isPrime:

print(n)

————————————–
Hit the thumbs up if you are fine with the answer. HappyLearning!

2692493 4632703 7983121 11505341 11505343 mport math # reading file f-open(“101prime.txt”).read().split() # considering each number for one in f: n-int (one)

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.