Is smart code smart?
When you are a beginner programmer, you are happy that your programs work at all, and you will not pay much attention to what your code looks like or how it performs. The important thing is that you get the result you want on the screen.
But as you get more experienced and learn more, you will start to embrace what you might consider smart solutions. A smart solution, for you, might be that you can rewrite 10 lines of code so that it now is done in three.
The question you always should ask yourself is whether changes that are made to working code improve it in any way. Only if they do will the new code be considered smarter than it was before.
Imagine that you wrote a little game in Python. It has a loop that runs 10 times, and in each iteration, it will ask the user for a number, either 0
or 1
. It will also randomly pick either a 0
or a 1
. If the user guessed the same number as the computer picked, the user wins; otherwise, the user loses. The code might...