# File: sumsq.py # sum the first few squares # # Matt Bishop, MHI 289I, Fall 2021 # # # read in the number to go to # try: upper = int(input("How many squares should I sum? ")) except SyntaxError: print("Not an integer ... please enter a positive integer!") except: print("Something went wrong") else: # # now be sure it's a positve integer # if upper > 0: # # add them up! # total = 0 for i in range(1, upper+1): total += i ** 2 print("The sum of the first", upper, "squares is", total) else: print("An integer, but not positive ... please enter a positive integer!")