# This program finds the sum of squares of first n postive integers, # where n is inputed by the user. def main(): print "This program finds the sum of squares of first n postive integers,", print "where n is inputed by the user." number=input("Please input any positive integer and press Enter:") answer=sumOfSquares(number) if answer != -1: print "The sum of squares of first",number,"positive integers is",answer else: print "Have a good day" # Finds the sum of squares of first n postive integers # returns -1 if the value n is not a positive integer, # otherwise, returns the sum def sumOfSquares(n): if type(n) != int: print "The value ",n,"is not an integer value.", print "Exiting the program ..." return -1 if n < 1: print "The value ",n,"is not positive.", print "Exiting the program ..." return -1 sq = 0 for k in range(n+1): sq += k*k return sq main()