๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

all prime numbers

โ† All Python Programs

Aim:

☛   Python program to print all prime numbers in a given interval (use break)

Solution :


PROGRAM: (prime_numbers.py)

 
lower_value = int ( input ( "Enter the Lowest Range Value: " ) )
upper_value = int ( input ( "Enter the Upper Range Value: " ) )
print ( "Prime numbers between " , lower_value , " and " , upper_value , " are : " )
for num in range ( lower_value , upper_value + 1 ) : 
	# all prime numbers are greater than 1 
	if num > 1 : 
		for i in range ( 2 , num) : 
			if ( num % i ) == 0 : 
				break 
		else : 
			print ( num , end = " \t " )

OUTPUT:

 
Enter the Lowest Range Value: 5
Enter the Upper Range Value: 36
Prime numbers between  5  and  36  are : 
5        7       11      13      17      19      23      29      31


๐Ÿ’ป Run This Python Program

all prime numbers
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals