Newbee Question

Ant antroy at gmail.com
Tue Aug 21 04:38:22 EDT 2007


On Aug 20, 11:47 pm, hd1... at yahoo.com wrote:
...
> Thanks for the help. By the way I am trying to learn the python after
> work and on weekends. If it was a dumb question, to this group, I will
> not bother you all again.

It's not so much that it was a dumb question, but that it was asked in
a dumb way :-) You'll get the most help in this group if you can show
some evidence that you've had a go (the size of this thread ironically
trounces that argument of course ;-) .)

It's better to learn if people give you a critique of your own attempt
at the code, rather than looking at other peoples efforts. There's a
guide on how to ask good questions here: http://www.catb.org/~esr/faqs/smart-questions.html

For what it's worth, here's a gratuitous version using generators, and
one you should come back to once you've mastered the basics of Python:

def counter(std_rate, over_rate, limit):
    stops = 0
    while True:
        stops += 1
        wage = stops * std_rate + max(0, stops - limit) * (over_rate -
std_rate)
        yield stops, wage

truck = counter(0.4, 1.4, 22)

for i in range(30):
    print "Stopped %s times, with accumulated wage of $%s" %
truck.next()

--
Ant...

http://antroy.blogspot.com/





More information about the Python-list mailing list