![]() |
Python beginner - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python beginner (/thread-11119.html) Pages:
1
2
|
RE: Python beginner - Grok_It - Jun-24-2018 (Jun-24-2018, 05:30 PM)gontajones Wrote: I completely agree with you. But maybe a beginner would read this and ask why the 'month' ('m' in my case) variable exists. for month in range(months): # count once for each month borrowed *= 1 + interest / 12 # & compound the interest borrowed -= repayment # & subtract repayment print(borrowed) # then, print the remaining amount borrowed ![]() If you add some comments it should be clear for all. I tutor online and I've found most students are sorely lacking commenting skills. RE: Python beginner - BigDisAok - Jun-25-2018 Thanks very much to you both for these answers :) I had no idea how to do this before so its good to see/learn this code! It workssssss! BigD RE: Python beginner - buran - Jun-25-2018 (Jun-24-2018, 05:37 PM)Grok_It Wrote: If you add some comments it should be clear for all. Sorry, but I would disagree. What you provide is really bad example of comments (or if you want - really good example of bad comments). Check PEP8 about inline comments Overuse of inline comments makes it hard to read the code and for simple lines (like these) are completely redundant. Good descriptive variable names would do. A short single-line block comment may be OK, but inline comments - definitely not. And given that it is actually a function - a docstring would be more than enough in this case (i.e. for a simple function like this one)... RE: Python beginner - Grok_It - Jun-25-2018 (Jun-25-2018, 10:18 AM)buran Wrote: Sorry, but I would disagree. What you provide is really bad example of comments (or if you want - really good example of bad comments). Check PEP8 about inline comments Not worth arguing over RE: Python beginner - buran - Jun-25-2018 (Jun-25-2018, 06:32 PM)Grok_It Wrote: So, you'd trade fast code for slow but denigrate comments that make the fast code clear for a beginner to understand? I don't know how you come to a conclusions what I would trade from my opinion about the comments you added to the code... You suggested adding comments so that it should "be clear for all" and I expressed my opinion about the comments you added to the code |