Check if this basic Python script is coded right
Joel Goldstick
joel.goldstick at gmail.com
Sat Oct 26 13:53:30 EDT 2013
On Sat, Oct 26, 2013 at 1:36 PM, HC <hikmat at jafarli.net> wrote:
> I'm doing my first year in university and I need help with this basic assignment.
>
> Assignment: Write Python script that prints sum of cubes of numbers between 0-200 that are multiples of 3. 3^3+6^3+9^3+12^3....+198^3=?
>
> My script:
> count = 0
> answer = 0
>
> while count<200:
> if count%3==0:
> answer = answer + count**3
> count = count + 1
>
> print ("Result is: " +str(answer))
>
> Is it all okay?
>
> Regards
> --
> https://mail.python.org/mailman/listinfo/python-list
You should run it to see what results you get. I am guessing that you
don't know the ultimate answer, but you could run it for a much
smaller number than 200 and check the results by hand.
--
Joel Goldstick
http://joelgoldstick.com
More information about the Python-list
mailing list