Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. print ("This calculates the sum of the cubes of the 1st natural numbers")
  2. natn = eval(input("How many cube numbers do you want to sum? "))
  3. print("sum of even cubes between 0 and {} : ".format(natn-1),sum(i**3 for i in range(0,natn,2)),"\n",
  4.       "sum of cubes between  0 and {}".format(natn-1),sum(i**3 for i in range(natn)),"\n",
  5.        "average of cubees between 0 and {}".format(natn-1),sum(i**3 for i in range(natn))/sum(1 for i in range(natn)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement