Python program that prints all prime numbers in a given range:
start = int(input("Enter the start of the range: "))
end = int(input("Enter the end of the range: "))
print("Prime numbers between", start, "and", end, "are:")
for num in range(start, end + 1):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
break
else:
print(num)
The program prompts the user to enter the start and end of the range using the input() function, and stores the values in the variables “start” and “end”. It then uses a for loop to iterate through the range of numbers between start and end (inclusive). For each number in the range, it uses another for loop to check if the number is prime. If the number is greater than 1, it checks if the number is divisible by any number between 2 and the number itself. If the number is divisible by any number between 2 and the number itself, it is not a prime number. If the number is not divisible by any number between 2 and the number itself, it is a prime number and it prints the number. If the number is less than or equal to 1, it is not a prime number.
You can also use the `math.sqrt