Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 07 08:29
    Chaenniee closed #150
  • Sep 07 08:28
    Chaenniee opened #150
  • Jul 18 20:06
    karimhbadr1 closed #149
  • Jul 18 20:06
    karimhbadr1 synchronize #149
  • Jul 18 20:04
    karimhbadr1 opened #149
  • Jul 18 13:33
    Nick-Z0 opened #148
  • Jun 27 11:39
    dabeaz commented #147
  • Jun 27 11:39
    dabeaz closed #147
  • Jun 27 10:43
    talghe synchronize #147
  • Jun 27 09:24
    talghe closed #146
  • Jun 27 09:19
    talghe synchronize #147
  • Jun 27 09:17
    talghe opened #147
  • Jun 27 08:24
    talghe commented #146
  • Jun 27 08:24
    talghe ready_for_review #146
  • Jun 27 08:23
    talghe opened #146
  • Jun 27 08:20
    talghe closed #145
  • Jun 27 08:19
    talghe ready_for_review #145
  • Jun 27 08:17
    talghe opened #145
  • Jun 22 11:13
    talghe synchronize #144
  • Jun 22 10:58
    talghe synchronize #144
Aleksey Tsalolikhin
@atsaloli_gitlab
Hello. Merry Christmas. Where can I find the reference documentation for the python slice notation? I noticed the start and stop defaults change when the step is negative, and I just want to find where that is documented.
Aleksey Tsalolikhin
@atsaloli_gitlab
I found https://docs.python.org/3/reference/expressions.html?highlight=slice#slicings but I don't see anything there about the start/stop defaults changing
Aleksey Tsalolikhin
@atsaloli_gitlab
Another question -- why does python round() x.5 to the nearest even number instead rounding it up like in math? that's surprising...
for example, round(1.5) comes out to 2; round (10.5) comes out to 10.
Aleksey Tsalolikhin
@atsaloli_gitlab
TIL about Banker's Rounding https://wiki.c2.com/?BankersRounding
Z Z
@ZZ939_gitlab
@sodiqafolayan Hello! The value of height changes at every iteration because you are multiplying height by 3/5 each time through the loop. Hope that helps.
Tom Nguyen
@tunggnu
@sodiqafolayan Physically, air resistance and floor friction cause height to be reduced.
sodiqafolayan
@sodiqafolayan

Dear all,

In the mortgage.py code as stated below, please can someone explain why we have (1+rate/12)
I am not able to wrap my head around why we need to add 1 to that line

principal = 500000.0
rate = 0.05
payment = 2684.11
total_paid = 0.0

while principal > 0:
principal = principal * (1+rate/12) - payment
total_paid = total_paid + payment

print('Total paid', total_paid)

Chalermsak Chatdokmaiprai
@Chalermsak-KU
Dear @dabeaz. I'm an old-time C programmer and learned Python basics from books. Last month I found this free online Practical Python Course and decided that this course is precisely what I need to upgrade my Python skills. Now that I've finally finished it, I would like to thank you for creating this superb course. Working myself carefully through the course is a great eye-opener, enlightening experience with lots of fun. It's a bit terse sometimes but, no problems, I can always google things for more details. This course has been a great compass for me in learning Python. Thank you very much to make it available for the world. Eagerly looking forward to your new Python book "Python distilled". :)
David Beazley
@dabeaz
Glad you liked the course!
Zac E.
@zac618
Started the course today...very new to this!
quas
@quas:matrix.org
[m]
Hello. Is there a solution for exercise 1.6 at the end? (https://github.com/dabeaz-course/practical-python/blob/master/Notes/01_Introduction/02_Hello_world.md)
I fixed it and it works, but it's always nice to have a look at the 'official' solution in case something pops up which I haven't thought of.
for the previous exercise there is a solution in the repo
quas
@quas:matrix.org
[m]
I have the same question for 1.11. I'm not sure if the solution give includes the solution there or not.
quas
@quas:matrix.org
[m]
is this channel active at all? does it make sense to reach anyone here?:)
quas
@quas:matrix.org
[m]
:point_up: Edit: I have the same question for 1.11. I'm not sure if the solution given includes the solution there or not.
David Beazley
@dabeaz
I monitor the channel, but I'm not able to give personalized help for course material. The Solutions/ directory has all of the posted solutions to most course exercises.
quas
@quas:matrix.org
[m]
I understand. So what is the purpose of this channel?
David Beazley
@dabeaz
If people want to chat about stuff, they can.
Sarfraaz Ahmed
@asarfraaz
In the Stock class, after we create "name", "shares" and "price" using typedproperty, we end up creating 3 new class variables in Stock. I noticed that slots no longer worked after this. What is the way to make use of slots in this case ? Or, do we no longer need slots because the attributes have now become properties ?
David Beazley
@dabeaz
__slots__ needs to specify the names where attribute values are actually stored. For something like a property, if the data is stored in an attribute like _name, then '_name' would need to appear in __slots__
1 reply
Thomas Ammitzbøll-Bach
@tabacdk
Hello David. Thank you so much for your effort. Do you have any instructions for generating the presentation? I would guess it is something that involves Pandoc or Spinx, but would you like to give some hints of what you do? Do you create Reveal.js slides or what?
David Beazley
@dabeaz
I don't have any presentation generation for the material here. Original source material was adapted from Keynote slides, but it's been reorganized slightly from that.
Thomas Ammitzbøll-Bach
@tabacdk
Hi David. Thanks for your reply. Yes, I will find a way, it is MD after all.
Widad Iqbal Mogral
@widadmogral
Hello, I am trying out Exercise 6.3: Making a more proper container and even after including the def getitem(self, index):
return self._holdings[index]
code in the Portfolio class, I am not able to get indexing to work properly. So for example trying
import report
portfolio = report.read_portfolio('Data/portfolio.csv')
>>>portfolio[0]
<stock.Stock object at 0x7f486b7b0c40>
instead of Stock('AA', 100, 32.2) as expected
>>> portfolio[0:3]
[<stock.Stock object at 0x7f486b7b0c40>, <stock.Stock object at 0x7f486b7b0f70>, <stock.Stock object at 0x7f486b7d4040>]
instead of [Stock('AA', 100, 32.2), Stock('IBM', 50, 91.1), Stock('CAT', 150, 83.44)] as expected.
Other functions like __len__ and __contains__ works as expected.
>>>len(portfolio)
7
>>> 'IBM' in portfolio
True
Anyone else who had the same issue or maybe any clue as to what I am doing wrong? Thanks in advance.
Sarfraaz Ahmed
@asarfraaz
I think you missed implementing __repr__ in Stock class
Widad Iqbal Mogral
@widadmogral
@asarfraaz , Thank you so much, I had indeed missed that.
1 reply
quas
@quas:matrix.org
[m]
After initially being a little bit reluctant, I realised that the course is actually great and that you somehow achieve to strike the right balance - the course is neither too easy, not extremely difficult, and you give students the chance to really think things over. So thank you for that @dabeaz :)
I followed several other courses before this, which helped anyway, but I seem to be able to be really making constant progress - even if it's slow (that's my fault :D ) - and the idea of taking a basic problem/task and build on it over and over is also a really intelligent pedagogical trick :)
David Beazley
@dabeaz
Glad to get the feedback! The course may not be the most "slick" thing, but it's the end product of teaching Python more than 300 times over a 12 year period. Hopefully others find it useful.
quas
@quas:matrix.org
[m]
I'm not sure to what extent it matters, but I'll mention it anyway. There's a typo here https://github.com/dabeaz-course/practical-python/blob/master/Notes/03_Program_organization/05_Main_module.md
It should be "interactively" instead of "interatively".
David Beazley
@dabeaz
Thanks! Fixed.
quas
@quas:matrix.org
[m]

Hello. For the sake of clarity: in the following example, here: https://github.com/dabeaz-course/practical-python/blob/master/Notes/03_Program_organization/05_Main_module.md#script-template, instead of:

# Main function
def main(argv):
    # Parse command line args, environment, etc.
    ...

shouldn't it have been def main(args), just like in the solution? I'm asking, because argv is very confusing in this context, given that you think automatically about sys.argv, which isn't supposed to appear in the definition. Or is that intentional so that the students can figure it out for themselves?

It took me quite a while to understand (not that I'm complaning, it's part of the learning process anyway)
quas
@quas:matrix.org
[m]

@dabeaz: Hello. I think there's a mistake here:
https://github.com/dabeaz-course/practical-python/blob/master/Notes/04_Classes_objects/01_Class.md

In the code in exercise 4.3, there's no attribute "cost":

sum([s.cost() for s in portfolio])
quas
@quas:matrix.org
[m]
I've realised I've overlooked the code snippet where cost(s) is defined, actually :)
Tinyu
@Tinyu-Zhao
I have a question about Exercise 1.11: Bonus, in my program 19 and 20 I made a judgment to avoid exceeding the principal but it doesn't work properly, I'm sorry
principal = 500000.0
rate = 0.05
payment = 2684.11
total_paid = 0.0
month = 0
extra_payment_start_month = 61
extra_payment_end_month = 108
extra_payment = 1000

while principal > 0:
    if extra_payment_end_month >= month >= extra_payment_start_month:
        payment = 2684.11 + extra_payment
        principal = principal * (1+rate/12) - (payment)
    else:
        payment = 2684.11
        principal = principal * (1+rate/12) - (payment)
        if payment >= principal:
            payment = principal
    month = month + 1
    total_paid = total_paid + payment
    print("%d %.2f %.2f" % (month, total_paid, principal))

print('Total paid %.2f , months: %d' % (total_paid, month))
4 replies
quas
@quas:matrix.org
[m]
I don't think you need to explicitly mention payment within the loop anyway (that 2684.11)
quas
@quas:matrix.org
[m]
in any case, if you were trying to 'fix' the logic, the total sum of that is paid is going to be more than the principal, if I understand it correctly, because of the interest or sth like that
quas
@quas:matrix.org
[m]
@Tinyu-Zhao: as far as I know the principle is the original borrowed sum of money. That is it. What you pay in the course of months/years is supposed to exceed the principle. At least this is my understanding.
If the total sum doesn't exceed the principle, who is the bank, which is loaning you money, supposed to earn money at all?
how is the bank*
So I'm not so sure this is a bug at all.
Kevin Sjöberg
@kevinsjoberg

In Chapter 4.2 Inheritance there's a statement towards the bottom.

or more information, you should probably look for books on the topic of design patterns

Any suggestions?

1 reply
quas
@quas:matrix.org
[m]
@dabeaz: the link here is wrong:
https://github.com/dabeaz-course/practical-python/blob/master/Notes/05_Object_model/02_Classes_encapsulation.md#decorator-syntax
"More details are given in Section 7." (Section 7 points to the link without the .md extension)
quas
@quas:matrix.org
[m]
ok, never mind. This channel is obstinately dead.
David Beazley
@dabeaz
Oh, I saw your comment. I was just a little preoccupied dealing with LIFE. For example, a busy holiday weekend, someone in the hospital, kids, and a dog. I'm SO SORRY for the level of service.
smilofactor
@smilofactor
test
lmind
@loadedmind
Is there a Discord or Slack presence for this channel? Those communication mediums typically draw more crowds. Before today, I had never heard of Gitter.
David Beazley
@dabeaz
I don't have the resources (both time and energy) to run active Discord/Slack channels for this course. However, by releasing this material as Creative Commons, people really are free to do with it as they wish. This would include creating communities elsewhere to discuss it. I might only ask that if someone does that, they should submit PR back to the course here with a link.