Math, asked by Anonymous, 6 months ago

*write a python program to print all prime numbers in an interval*

computer chapter-11 python program

please answer my question​....​

Answers

Answered by meetsinghBagga
21

Answer:

#Take the input from the user:

lower = int(input("Enter lower range: "))

upper = int(input("Enter upper range: "))

for num in range(lower,upper + 1):

if num > 1:

for i in range(2,num):

if (num % i) == 0:

break

else:

print(num)

Step-by-step explanation:

HOPE THIS HELPS YOU

PLEASE MARK AS BRAINLIEST

Answered by Anonymous
44

Required Answer :

Question:

  • Write a python program to print all prime numbers in an interval.

Program:

This is the required python program for the question.

# Python program to display all the prime numbers within an interval

# change the values of lower and upper for a different result

lower = 900

upper = 1000

# uncomment the following lines to take input from the user

#lower = int(input("Enter lower range: "))

#upper = int(input("Enter upper range: "))

print("Prime numbers between",lower,"and",upper,"are:")

for num in range(lower,upper + 1):

# prime numbers are greater than 1

if num > 1:

for i in range(2,num):

if (num % i) == 0:

break

else:

print(num)

Output:

The output of the program will be as follows:

Prime number between 900 and 1000 are:

907

911

919

929

937

941

947

953

967

971

977

983

991

997.

Attachments:
Similar questions