0% found this document useful (0 votes)
17 views3 pages

Assignment Worksheet Python Sai Assesment

assignment

Uploaded by

maivagii70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Assignment Worksheet Python Sai Assesment

assignment

Uploaded by

maivagii70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Worksheet 1.4

Student Name: SAI THARUN UID: 23BCS13208


Branch: CSE Section/Group: 23BCS804-B
Semester: 3 Date of Performance:18/07/24
Subject Name: Python Programming Subject Code: 23CSP-201

Aim : Prime Number Finder


You are creating a program to find prime numbers within a given range. This tool will help
users understand prime numbers and practice implementing mathematical algorithms using
basic Python concepts.

Requirements:
1. Determine if a number is prime.
2. Accept user input for the start and end of a range of numbers.
3. Find and display all prime numbers within the given range.
4. Count the total number of prime numbers found.

Program:
def is_prime(num):
if num <= 1:
return False
for i in range(2, int(num**0.5) +1):
if num % i == 0
return False
return True
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

# Taking user input for the range


start_range = int(input("Enter the
start of the range: "))
end_range = int(input("Enter the end
of the range: "))

# Printing the prime numbers in the


given range
print(f"Prime numbers between
{start_range} and {end_range} are:")
for num in range(start_range,
end_range + 1):
if is_prime(num):
print(num, end=" ")
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

OUTPUT:

You might also like