- 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

# Python Program to Find all Numbers in a Range which are Perfect Squares and Sum of all Digits in the Number is Less than 10

When it is required to find all numbers in a range where there are perfect square, and sum of digits in the number is less than 10, list comprehension is used.

Below is the demonstration of the same −

## Example

lower_limit = int(input(“Enter the lower range: “)) upper_limit = int(input(“Enter the upper range: “)) my_list = [] my_list = [x for x in range(lower_limit,upper_limit+1) if (int(x**0.5))**2==x and sum(list(map(int,str(x))))<10] print(“The result is : “) print(my_list)

## Output

Enter the lower range: 5 Enter the upper range: 12 The result is : [9]

## Explanation

The lower range and upper range are taken by the user.

An empty list is defined.

The list comprehension is used, to iterate over the lower and upper limits.

The square root of the elements are found.

The elements are summed up.

It is converted to a list.

This is assigned to a variable.

The output is displayed on the console.

- Related Questions & Answers
- Program to find sum of two numbers which are less than the target in Python
- Python Program to Find All Numbers which are Odd and Palindromes Between a Range of Numbers
- Program to find the sum of all digits of given number in Python
- Recursive program to print all numbers less than N which consist of digits 1 or 3 only in C++
- Is a number sum of two perfect squares in JavaScript
- Count all the numbers less than 10^6 whose minimum prime factor is N C++
- Find the element before which all the elements are smaller than it, and after which all are greater in Python
- Program to find list of elements which are less than limit and XOR is maximum in Python
- Program to find number not greater than n where all digits are non-decreasing in python
- Print a number strictly less than a given number such that all its digits are distinct in C++
- Find all factorial numbers less than or equal to n in C++
- Program to find nearest number of n where all digits are odd in python
- Count numbers which are divisible by all the numbers from 2 to 10 in C++
- Recursive sum all the digits of a number JavaScript
- Destructively Sum all the digits of a number in JavaScript

Advertisements