# ==============================================================================
"""SQUARES : print the sequence of square numbers from 1*1 to n*n"""
# ==============================================================================
__author__  = "Christophe Schlick modified by Philippe Blasi"
__version__ = "1.0" # use 'while' loop to generate string
__date__    = "2022-11-12"
__usage__   = """
User input: <n> (where n:int > 0)
App output: sequence of square numbers from 1*1 to n*n"""
# ==============================================================================
from ezCLI import *
# ------------------------------------------------------------------------------
def square(n:int) -> int:
  """return the square of 'n'"""
  return n*n
# ------------------------------------------------------------------------------
def squares(n:int) -> str:
  """return a string containing the 'n' first square numbers"""
  p, lines = 1, ''
  while (p <= n):
    lines += f"{p} * {p} = {square(p)}\n"
    p += 1; #inspect()
  return lines.strip() # remove trailing newline character
# ------------------------------------------------------------------------------
def parser(command:str) -> str:
  """parse 'command' as integer 'n' before calling 'squares(n)'"""
  n = parse(command); #inspect()
  assert type(n) is int and n > 0, "<n> must be a strictly positive integer"
  return squares(n)
# ==============================================================================
if __name__ == '__main__':
  userloop(parser, "Enter value for <n>")
# ==============================================================================
