In this example we will show how to find out all perfect squares among given numbers of which the sum is less than 10 with Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
lowerLimit = int(input("Please input the lower limit: "))
upperLimit = int(input("Please input the upper limit: "))
print("The numbers we found are: ")
for i in range(lowerLimit, upperLimit+1):
if (int(i ** 0.5)) ** 2 == i and sum(list(map(int, str(i)))) < 10:
print(i, sep=" ", end="\t")
print()
Output:
Please input the lower limit: 100
Please input the upper limit: 200
The numbers we found are:
100 121 144