Question: # ! / usr / bin / env python # coding: utf - 8 # In [ ] : import math invalid = True #The

#!/usr/bin/env python
# coding: utf-8
# In[]:
import math
invalid=True
#The 'display_banner()' function prints a header to provide a visual indication that the program has started.
def display_banner():
print("*******************************************")
print("****** SQUARE NUMBER FINDER ***************")
print("*******************************************")
#The get_valid_number(prompt, lower_bound, upper_bound) function is responsible for
#getting user input and ensuring it meets the specified criteria.
def get_valid_number(prompt, lower_bound, upper_bound):
while invalid:
try:
value = int(input(prompt))
if lower_bound <= value <= upper_bound:
return value
invalid=True
else:
print(f"Invalid input: Please enter a number between {lower_bound} and {upper_bound}.")
invalid=False
except ValueError:
print("Invalid input: Please enter a whole number.")
#The 'find_square_numbers(lower_limit, upper_limit)' function computes all the square
#numbers within the provided range.
#starts from the smallest integer whose square is greater than or equal to 'lower_limit' and
#goes up to the largest integer whose square is less than or equal to 'upper_limit'.
#For each integer i in this range, it calculates 'i**2' and appends a tuple '(square_number, i)'
#to the 'square_numbers' list.
def find_square_numbers(lower_limit, upper_limit):
square_numbers =[]
for i in range(math.ceil(math.sqrt(lower_limit)), math.floor(math.sqrt(upper_limit))+1):
square_number = i **2
if lower_limit <= square_number <= upper_limit:
square_numbers.append((square_number, i))
return square_numbers
#The 'display_square_numbers(square_numbers)' function prints each square number along with its square root.
def display_square_numbers(square_numbers):
print(f"Square Numbers Between {lower_limit} and {upper_limit}")
for number, root in square_numbers:
print(f"{number}({root} squared)")
display_banner()
lower_limit = get_valid_number("Please enter the lower bound: ",1,10000)
upper_limit = get_valid_number("Please enter the upper bound: ", lower_limit,10000)
square_numbers = find_square_numbers(lower_limit, upper_limit)
display_square_numbers(square_numbers)
input("Press Enter to close the program...")
# In[]:
PLEASE DONT USE INFINTE LOOP, AS IN WHILE TRUE.
Can you please make this code more human?
Please also provide plan for the code.
Please also provide Pseoudocode. as in expected output, actual output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!