Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.149 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.74; '*S*': 0.04; 'subject:Python': 0.06; 'get.': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'assignment.': 0.16; 'guessing': 0.16; 'multiples': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'prints': 0.31; 'run': 0.32; 'url:python': 0.33; 'could': 0.34; 'basic': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'url:org': 0.36; 'should': 0.36; 'pm,': 0.38; 'university': 0.39; 'url:mail': 0.40; 'numbers': 0.61; 'first': 0.61; 'sum': 0.64; 'skip:+ 10': 0.65; 'between': 0.67; '26,': 0.68; 'results': 0.69; 'subject:this': 0.83; 'cubes': 0.84; 'hand.': 0.84; 'joel': 0.91; 'ultimate': 0.93; 'subject:Check': 0.95; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=7RQaB4cM7FVIDKvYRv5ZS0NBGscluz9IqfqYd8I4chI=; b=YeiZDACgfIxQl/plnS6LdH+hnQJqqqQ8BO7wYG1DCvcpZ7qFhw8jRVUCDce8C3UWag LILhAwbl+Kip/vUciMbnFHRw7RqqQslfs7m2E4CO+J1yKOAflIyuZmbHn4Kwc5FM6j4y YVLeLjhq5Wvv+Xe3yQ0k+OGy/EPc7656OdQ4wwyYO2Y24DBHMfAAz3Z50R+uUeyPARhP FkpRe13LTT9WEoNvOx1cDWdwnEMVjdb7J0IcpKk0FnVyn/OARBKoaxh0Iew831DyXBZa YNNRCRhCkTKTldKy4b0PVY2RdWLNR6X6/iKc9XZRPjsN41UXabUwzkWsBaYBN7vlgdUf +WQQ== MIME-Version: 1.0 X-Received: by 10.52.98.99 with SMTP id eh3mr6601815vdb.29.1382810010478; Sat, 26 Oct 2013 10:53:30 -0700 (PDT) In-Reply-To: <9716695c-31e3-40a0-b2a4-73b967494107@googlegroups.com> References: <9716695c-31e3-40a0-b2a4-73b967494107@googlegroups.com> Date: Sat, 26 Oct 2013 13:53:30 -0400 Subject: Re: Check if this basic Python script is coded right From: Joel Goldstick To: HC Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382810012 news.xs4all.nl 15962 [2001:888:2000:d::a6]:59529 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57639 On Sat, Oct 26, 2013 at 1:36 PM, HC 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