- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution and approach to solve the given problem statement.

Given the starting and ending range of an interval. We need to print all the numbers in the interval given.

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

There are two for loops, first for loop is for getting the numbers in the interval and second loop for the checking whether the number is prime or not.

Now let’s see the implementation.

start = 10 end = 29 for val in range(start, end + 1): # If num is divisible by any number is not prime if val > 1: for n in range(2, val): if (val % n) == 0: break else: print(val)

11 13 17 19 23 29

All variables and functions are declared in the global scope as shown in the figure below.

In this article, we learned about the approach to print numbers in a given interval.

- Related Questions & Answers
- Python program to print all Prime numbers in an Interval
- How to Print all Prime Numbers in an Interval using Python?
- Program to count odd numbers in an interval range using Python
- Program to find one minimum possible interval to insert into an interval list in Python
- Python program to print even numbers in a list
- Python program to print negative numbers in a list
- Python program to print odd numbers in a list
- Python Program to Print an Identity Matrix
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Program to find Prime Numbers Between given Interval in C++
- How to identify and print all the perfect numbers in some closed interval [ 2, n ] using Python?
- Python Program to Print an Inverted Star Pattern
- Python program to print all Disarium numbers between 1 to 100
- Program to print numbers columns wise in C

Advertisements