Skip to main content

Timeline for Transform dollars in exact change

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
Feb 27, 2020 at 20:29 comment added Traveler @pete I appreciate the feedback very much, I will look more into using more functions. See how well I can do on my next way around. I have looked into them a few times, but did not see where or when to do it, that example you gave really helps me see it how it works first hand, and hope to nail it soon! I agree with the commenting, it was late at night when I did that, though not an excuse I will keep in mind to leave those bits out.
Feb 27, 2020 at 20:24 vote accept Traveler
Feb 27, 2020 at 17:10 comment added Seth R In addition to avoiding profanity in comments, it is usually better to avoid comments altogether if it is obvious what the code is doing. I don't need a comment to tell me what print('No change') or if change <= 4: does. I can tell that by reading the code. You only need a comment if it may not be clear why it was done that way. I.e. don't use comments to explain what the code does, just why it's there.
Feb 27, 2020 at 14:43 comment added AlexV @acdr Luckily other languages are not a major concern in that case and Python has divmod ;-)
Feb 27, 2020 at 13:52 comment added acdr Keep in mind that these repeated calls to calculate_coins_of_denomination could also be rolled into a loop, like num_coins = {}, for (denom, name) in [(100, "dollars"), (25, "quarters"), ... (1, "pennies")]: num_coins[name], change = calculate_coins_of_denomination(change, denom)
Feb 27, 2020 at 13:49 comment added acdr Also perhaps consider using the divmod function. Won't be available in every language, but it'll clean up your relatively ugly return line.
Feb 27, 2020 at 11:41 comment added AlexV Just a note: putting explicit parentheses around num_X, change is not necessary, and I would argue that they don't improve the readability here.
Feb 27, 2020 at 11:08 history answered Pete CC BY-SA 4.0