Getting started with python

E

Eric

Hello, after reading some of the book Programming Python it seems that
python is something I would like to delve deeper into. The only thing
is, I have no idea what I should try and write. So I was hoping that
someone here could help point me to a group/project that would be a
good starting place for a person with limited python knowledge, but
that is willing to learn whatever is necessary. I'm hoping that with a
goal I can start to learn python instead of just playing around with
it. Thanks.
 
S

somas1

I'd like to second this request or at least find out if there are any
type of Python mentorship programs I could join.
 
P

Paddy

Hello, after reading some of the book Programming Python it seems that
python is something I would like to delve deeper into. The only thing
is, I have no idea what I should try and write. So I was hoping that
someone here could help point me to a group/project that would be a
good starting place for a person with limited python knowledge, but
that is willing to learn whatever is necessary. I'm hoping that with a
goal I can start to learn python instead of just playing around with
it. Thanks.

Hi Eric, Somas1.
Try:
http://www.google.co.uk/search?sour...programming-problems&btnG=Google+Search&meta=

Some of the sites have beginners problems meant for
another language, but in a lot of cases that doesn't
matter.

You might need to be a fair way through the Python
tutorial though before you attempt thhem so you
know the basics of Python first.

On a different tack, from:
http://tickletux.wordpress.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
It seems you need to learn how to write a Fizz-Buzz
program to get a job now-a-days :)

- Paddy.
 
J

James Stroud

Eric said:
Hello, after reading some of the book Programming Python it seems that
python is something I would like to delve deeper into. The only thing
is, I have no idea what I should try and write. So I was hoping that
someone here could help point me to a group/project that would be a
good starting place for a person with limited python knowledge, but
that is willing to learn whatever is necessary. I'm hoping that with a
goal I can start to learn python instead of just playing around with
it. Thanks.

Here is a protocol I have used in the past:

1. Realize there is a program you really wish you had.
2. Find out that, upon relentless googling, no
such program exists that meets your needs exactly.
3. If 2 fails and a program exists, go back to 1.
4. Proceed to write this program no matter what it takes--you
may even face some "sitdowns" with your friends, family,
and/or employers.
5. (Very important)
A. Refer to this list periodically for help but making
sure to properly phrase you questions.
B. Try not to rewrite any libraries by first ascertaining
whether a library doesn't already exist for the
sub-task you are programming.
6. Enjoy the new program you have written and the new
knowledge you have gained.

James
 
E

Eric_Dexter

Hello, after reading some of the book Programming Python it seems that
python is something I would like to delve deeper into. The only thing
is, I have no idea what I should try and write. So I was hoping that
someone here could help point me to a group/project that would be a
good starting place for a person with limited python knowledge, but
that is willing to learn whatever is necessary. I'm hoping that with a
goal I can start to learn python instead of just playing around with
it. Thanks.

If you want to play around with simple graphics and writing simple
ascii files to disk then dex tracker may be a good project for you. I
am currently playing around with generating random sounds to disk and
random rythoms. (I also have a harder graphics problem that when I
solve will break the music program wide open). https://sourceforge.net/projects/dex-tracker
You would go to the (project homepage) website for dependencies
http://www.stormpages.com/edexter/csound.html (not all are required
for all sub-programs but you do want wxwindows). It would probily be
cool to expand the idea into non-random series of numbers and I have
just started to code this particular tool. I can upload it to my
google groups if you are intrested
 
E

Eric_Dexter

Hello, after reading some of the book Programming Python it seems that
python is something I would like to delve deeper into. The only thing
is, I have no idea what I should try and write. So I was hoping that
someone here could help point me to a group/project that would be a
good starting place for a person with limited python knowledge, but
that is willing to learn whatever is necessary. I'm hoping that with a
goal I can start to learn python instead of just playing around with
it. Thanks.

I have a little sub-project where I generate random numbers to a music
file (a simpe ascii format that works in a grid)
http://www.stormpages.com/edexter/csound.html or if you see some other
part of it you would like to work on or expand..
https://sourceforge.net/projects/dex-tracker I haven't added the sub-
project yet but I can upload it to some google space if you are
intrested.. (uses wxwindows and python 2.5)
 
D

Dorai

Here is a protocol I have used in the past:

1. Realize there is a program you really wish you had.
2. Find out that, upon relentless googling, no
such program exists that meets your needs exactly.
3. If 2 fails and a program exist s, go back to 1.
4. Proceed to write this program no matter what it takes--you
may even face some "sitdowns" with your friends, family,
and/or employers.
5. (Very important)
A. Refer to this list periodically for help but making
sure to properly phrase you questions.
B. Try not to rewrite any libraries by first ascertaining
whether a library doesn't already exist for the
sub-task you are programming.
6. Enjoy the new program you have written and the new
knowledge you have gained.

James

Start out with something simple and go deeper. For example, here is
one progression:

1. A simple program that counts words (wc) - read from a file,
tokenize, count
2. A variation of wc that does word frequency count (counts how many
times each word occurs) - wfc - In addition to 1, this allows you to
use a data structure to store words and search for them to update the
count. You may also sort the output.
3. A variation of wfc that reads from a file a set of noise words and
stores them in memory. As you are tokenizing, drop the noise words
from counting (or count noise words)

You could do similar things with database programming (start with
something simple and gradually increase the level of complexity or any
other area.

You can also access Python cookbook, use the examples as a starting
point and build variations. This not only allows you to read some well
written code but also understand various techniques.

Another suggestion is to get hold of a book "Software Tools" and try
to code all the examples in Python.

I found the best way to learn a language is to read some code, write
some code and keep improving it. Many improvements will suggest
themselves as you keep coding.

Hope this helps.

Dorai
www.thodla.com
 
G

Gabriel Genellina

Something less idiotic? I took longer to type a program to do that than
to
figure out how to do that.

We've used it as part of a test a few weeks ago. You'd be surprised on how
many guys couldn't write anything remotely sensible.
 
J

James Stroud

Gabriel said:
We've used it as part of a test a few weeks ago. You'd be surprised on
how many guys couldn't write anything remotely sensible.

--Gabriel Genellina

py> for i in xrange(1,101):
.... if not i % 15:
.... print 'fizzbuzz'
.... continue
.... if not i % 5:
.... print 'buzz'
.... continue
.... if not i % 3:
.... print 'fizz'
.... else:
.... print i
....

I typed this without so much as hitting delete. Didn't time it but I'm
guessing less than 2 minutes. How much am I worth a year? (Hopefully
capitalization is not important for this exercise.)

James
 
S

Steve Holden

James said:
py> for i in xrange(1,101):
... if not i % 15:
... print 'fizzbuzz'
... continue
... if not i % 5:
... print 'buzz'
... continue
... if not i % 3:
... print 'fizz'
... else:
... print i
...

I typed this without so much as hitting delete. Didn't time it but I'm
guessing less than 2 minutes. How much am I worth a year? (Hopefully
capitalization is not important for this exercise.)
You'd be worth more if you'd used elif and omitted the continue
statements, but for a first solution it's acceptable.

For better readability I'd have used

if i % 5 == 0

rather than

if not i % 5

but that's mostly a stylistic matter.

regards
Steve
regards
Steve
 
S

Steve Holden

James said:
py> for i in xrange(1,101):
... if not i % 15:
... print 'fizzbuzz'
... continue
... if not i % 5:
... print 'buzz'
... continue
... if not i % 3:
... print 'fizz'
... else:
... print i
...

I typed this without so much as hitting delete. Didn't time it but I'm
guessing less than 2 minutes. How much am I worth a year? (Hopefully
capitalization is not important for this exercise.)
You'd be worth more if you'd used elif and omitted the continue
statements, but for a first solution it's acceptable.

For better readability I'd have used

if i % 5 == 0

rather than

if not i % 5

but that's mostly a stylistic matter.

regards
Steve
regards
Steve
 
C

chengzhiannahuang

I have a little sub-project where I generate random numbers to a music
file (a simpe ascii format that works in a grid)http://www.stormpages.com/edexter/csound.htmlor if you see some other
part of it you would like to work on or expand..https://sourceforge.net/projects/dex-trackerI haven't added the sub-
project yet but I can upload it to some google space if you are
intrested.. (uses wxwindows and python 2.5)

I just installed Python 2.5 a few days ago. I like to play with
csound.
However, I am a window user knowing Java and C#. I do not have any
experience with unix system and c. I appreciate if you would send me
some instructions and examples to get me started so that In the
future, I can use midi input and get ourput from csound with a final
objective to generate some music not representable by midi.

Chin
 
P

Paul Rubin

Steve Holden said:
You'd be worth more if you'd used elif and omitted the continue
statements, but for a first solution it's acceptable.

For better readability I'd have used
if i % 5 == 0

I think I'd be more concerned about getting rid of the i%15 test.
What if a few more words get added?

def fizzbuzz(n):
words = ((3, 'Fizz'), (5, 'Buzz'), (7, 'Jazz'), (11, 'Pizzazz'))
r = ''.join(b for a,b in words if n%a == 0)
return r or str(n)

for i in xrange(1,101):
print fizzbuzz(i)
 
J

James Stroud

Paul said:
I think I'd be more concerned about getting rid of the i%15 test.
What if a few more words get added?

def fizzbuzz(n):
words = ((3, 'Fizz'), (5, 'Buzz'), (7, 'Jazz'), (11, 'Pizzazz'))
r = ''.join(b for a,b in words if n%a == 0)
return r or str(n)

for i in xrange(1,101):
print fizzbuzz(i)

I think that this is somewhat of an over-interpretation of the
specification.

1. This doesn't act according to the specification if you add, for
example, (2, 'Zonk'). Now 30 gives 'ZonkFizzBuzz' and not 'FizzBuzz'
according to the specification.

2. What if additional words don't necessarily follow the pattern you
infer? Nothing in the specification disallows adding (30, 'Whammo').

So, I would keep my original explicit testing:

def fizzbuzz(n):
words = ((30, 'Whammo'), (15, 'FizzBuzz'),
(5, 'Fizz'), (3, 'Buzz'), (2, 'Zonk'))
for k,v in words:
if not k % n:
return v
return n

for i in xrange(1,101):
print fizzbuzz(i)




James
 
P

Paul Rubin

James Stroud said:
1. This doesn't act according to the specification if you add, for
example, (2, 'Zonk'). Now 30 gives 'ZonkFizzBuzz' and not 'FizzBuzz'
according to the specification.

Correct, the original specification only had 3 and 5. I gave a longer
example to illustrate how the specification might be modified. Obviously
it is not the same specification any more. The i%15 approach gets messy
once there are more than two numbers to check.
So, I would keep my original explicit testing:
def fizzbuzz(n):
words = ((30, 'Whammo'), (15, 'FizzBuzz'),
(5, 'Fizz'), (3, 'Buzz'), (2, 'Zonk'))
for k,v in words:
if not k % n:
return v
return n

I don't think that's in the spirit of the original, which
would be to print 'BuzzZonk' for n=6.
 
J

James Stroud

Steve said:
You'd be worth more if you'd used elif and omitted the continue
statements, but for a first solution it's acceptable.

Depends on what you are after.

py> s = """
.... for i in xrange(1,101):
.... if not i % 15:
.... continue
.... if not i % 5:
.... continue
.... if not i % 3:
.... continue
.... else:
.... pass
.... """
py> t = timeit.Timer(stmt=s)
py> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
40.49 usec/pass
py> s = """
.... for i in xrange(1,101):
.... if not i % 15:
.... pass
.... elif not i % 5:
.... pass
.... elif not i % 3:
.... pass
.... else:
.... pass
.... """
py> t = timeit.Timer(stmt=s)
py> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
40.88 usec/pass

James
 
E

Eric_Dexter

I just installed Python 2.5 a few days ago. I like to play with
csound.
However, I am a window user knowing Java and C#. I do not have any
experience with unix system and c. I appreciate if you would send me
some instructions and examples to get me started so that In the
future, I can use midi input and get ourput from csound with a final
objective to generate some music not representable by midi.

Chin- Hide quoted text -

- Show quoted text -

Csound is based on c but as a csound user you don't realy need to
know... just take the instruments that are already available for
free.. Dex Tracker is just an interface to make it easier and provide
other tools.. more info on csound including manuals exc can be found
at http://www.csounds.com
 
T

tleeuwenburg

The Python Papers (http://pythonpapers.org) is another resource for
Python developers, especially those interested in keeping tabs on the
various projects and articles out there in the community.

Cheers,
-T (Editor-In-Chief, The Python Papers)
 
7

7stud

py> t = timeit.Timer(stmt=s)
py> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
40.88 usec/pass

What does this accomplish:

1000000 * t.timeit(number=100000)/100000

that the following doesn't accomplish:

10 * t.timeit(number=100000)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top