+ 5
Halloween Candy
When I go through other people's answers of how this should be solved, I notice that the answers are made up out of multiple lines of codes (3, 4, 5 or sometimes even more). My own answer got all pushed into one line like this (2 lines counting the already existing line); houses = int(input()) #your code goes here print (int(round(((2/houses)*100)+0.5))) My question is, what's better for professional settings? Is it better for me to write multiple lines (maybe it's easier to oversee?), or keep trying to keep it short?
3 odpowiedzi
+ 7
When u write a code u should respect this princips 🌟:
1-readability : when programming, the readability of the source code will often be more important than the number of lines of code.
2- maintainability : Short and confusing code can be difficult to maintain. It may result in problems like bugs and higher overhead costs during quality maintenance. It can also cause motivational issues and plain hullabaloo for you as a developer.
3- efficiency : Fewer lines of code can achieve the same results (and probably better) than many lines of code. If you reduce the amount of code in a task, you will lower the bug count, especially if the source code is clear, readable, and maintainable.Also, writing long lines of code may require you to include too many local variables, since you have to formulate names for them. All those different names can lead to confusion and inefficient programs.
+ 3
Michelle ♡
If it is possible to make short code then yes definitely you should keep trying to make short codes. There is no professional way to write code. The professional way is you should always use proper syntax, you should write comment in code, you should make small methods or functions, code should be readable.
+ 2
Mohamed WB That makes sense. I appreciate you taking the time to answer!