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


Groups > comp.lang.python > #80142

Re: what can i do to improve my skill after finished python course on codecademy

Date 2014-11-02 17:07 -0500
From Dave Angel <davea@davea.name>
Subject Re: what can i do to improve my skill after finished python course on codecademy
References (4 earlier) <m35hda$liv$1@ger.gmane.org> <mailman.15411.1414948574.18130.python-list@python.org> <4c0d5apoa3455vmkgdtp7nn25pl85fgmoh@4ax.com> <mailman.15414.1414957509.18130.python-list@python.org> <d26d5adlmfnkaji1ico6dpv9djah2obp1m@4ax.com>
Newsgroups comp.lang.python
Message-ID <mailman.15419.1414966072.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 11/02/2014 04:03 PM, Seymore4Head wrote:
> On Sun, 02 Nov 2014 19:42:49 +0000, Mark Lawrence
> <breamoreboy@yahoo.co.uk> wrote:
>
>> On 02/11/2014 19:10, Seymore4Head wrote:
>>> On Sun, 2 Nov 2014 12:16:11 -0500, Joel Goldstick
>>> <joel.goldstick@gmail.com> wrote:
>>>
>>>> On Sun, Nov 2, 2014 at 10:08 AM, Peter Otten <__peter__@web.de> wrote:
>>>>> Huhuai Fan wrote:
>>>>>
>>>>>> Thanks for your help, but i have no idea to find a project that i can
>>>>>> complete,i am now in perplexed for what to do
>>>>>
>>>>> Then write a small text-based brainstorming app!
>>>>>
>>>>> --
>>>>> https://mail.python.org/mailman/listinfo/python-list
>>>>
>>>> If you like math puzzles you can do the euler project stuff
>>>
>>> target=1000
>>> thelist=[]
>>> thesum=0
>>> for x in range (1,target):
>>>       if x%3==0: thelist.append(x)
>>>       if x%5==0 and x%3!=0: thelist.append(x)
>>> for x in thelist: thesum+=x
>>> print(thelist)
>>> print (thesum)
>>>
>>
>> In [1]: help(sum)
>> Help on built-in function sum in module builtins:
>>
>> sum(...)
>>      sum(iterable[, start]) -> value
>>
>>      Return the sum of an iterable of numbers (NOT strings) plus the value
>>      of parameter 'start' (which defaults to 0).  When the iterable is
>>      empty, return start.
>
> BTW I have the answer to question 2, but there is no way I would run
> the code on numbers much more than 100000 and it wants the answer for
> 4,000,000.
>

So that's teaching you that there must be a more elegant approach than 
brute-force.  Sometimes you can use cleverer programming, sometimes you 
need cleverer math.  Sometimes both.

As a trivial example, suppose you're asked to sum the numbers from 1000 
to 10**25

Brute force would take a few millenia, as something like
     ans = sum(range( BIG ) - sum(range(1000))

But just knowing the math lets you simplify it to something like
    ans = (1000 + BIG) * (BIG - 1000) / 2

(give or take a few plus/minus ones)



-- 
DaveA

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


Thread

what can i do to improve my skill after finished python course on codecademy fanhuhuai@gmail.com - 2014-11-01 08:01 -0700
  Re: what can i do to improve my skill after finished python course on codecademy alister <alister.nospam.ware@ntlworld.com> - 2014-11-01 22:01 +0000
    Re: what can i do to improve my skill after finished python course on codecademy Chris Angelico <rosuav@gmail.com> - 2014-11-02 09:10 +1100
    Re: what can i do to improve my skill after finished python course on codecademy Grant Edwards <invalid@invalid.invalid> - 2014-11-02 00:31 +0000
      Re: what can i do to improve my skill after finished python course on codecademy MRAB <python@mrabarnett.plus.com> - 2014-11-02 00:55 +0000
      Re: what can i do to improve my skill after finished python course on codecademy Chris Angelico <rosuav@gmail.com> - 2014-11-02 12:02 +1100
        Re: what can i do to improve my skill after finished python course on codecademy Grant Edwards <invalid@invalid.invalid> - 2014-11-02 17:30 +0000
      Re: what can i do to improve my skill after finished python course on codecademy Huhuai Fan <fanhuhuai@gmail.com> - 2014-11-02 06:49 -0800
        Re: what can i do to improve my skill after finished python course on codecademy Peter Otten <__peter__@web.de> - 2014-11-02 16:08 +0100
        Re: what can i do to improve my skill after finished python course on codecademy Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-02 12:16 -0500
          Re: what can i do to improve my skill after finished python course on codecademy Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-02 14:10 -0500
            Re: what can i do to improve my skill after finished python course on codecademy Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-02 19:42 +0000
              Re: what can i do to improve my skill after finished python course on codecademy Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-02 15:45 -0500
              Re: what can i do to improve my skill after finished python course on codecademy Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-02 16:03 -0500
                Re: what can i do to improve my skill after finished python course on codecademy Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-02 17:00 -0500
                Re: what can i do to improve my skill after finished python course on codecademy Dave Angel <davea@davea.name> - 2014-11-02 17:07 -0500
                Re: what can i do to improve my skill after finished python course on codecademy Chris Angelico <rosuav@gmail.com> - 2014-11-03 09:12 +1100
        Re: what can i do to improve my skill after finished python course on codecademy Abhiram <abhi.darkness@gmail.com> - 2014-11-02 22:51 +0530

csiph-web