Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57639

Re: Check if this basic Python script is coded right

References <9716695c-31e3-40a0-b2a4-73b967494107@googlegroups.com>
Date 2013-10-26 13:53 -0400
Subject Re: Check if this basic Python script is coded right
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1592.1382810012.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Oct 26, 2013 at 1:36 PM, HC <hikmat@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Check if this basic Python script is coded right HC <hikmat@jafarli.net> - 2013-10-26 10:36 -0700
  Re: Check if this basic Python script is coded right Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-26 13:53 -0400
  Re: Check if this basic Python script is coded right Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-26 18:55 +0100
  Re: Check if this basic Python script is coded right John Ladasky <john_ladasky@sbcglobal.net> - 2013-10-26 10:58 -0700
  Re: Check if this basic Python script is coded right MRAB <python@mrabarnett.plus.com> - 2013-10-26 19:20 +0100
    Re: Check if this basic Python script is coded right rusi <rustompmody@gmail.com> - 2013-10-27 05:20 -0700
      Re: Check if this basic Python script is coded right Tim Delaney <timothy.c.delaney@gmail.com> - 2013-10-28 08:30 +1100
  Re: Check if this basic Python script is coded right Terry Reedy <tjreedy@udel.edu> - 2013-10-26 15:46 -0400
  Re: Check if this basic Python script is coded right Terry Reedy <tjreedy@udel.edu> - 2013-10-26 16:16 -0400

csiph-web