Not sure I follow your question, though I sense some vexation. When it becomes necessary to calm down, nothing does more good than a kilometer walk.
I always have music going through my head so don’t need a walkman, just the beat of my steps. Steps are taken one at a time, and are generally quite in sync with one another, hence a beat.
The general sameness of each step (or pair of steps to arrive at the same foot) can be thought of as a unit measure of time, and of distance. Once we know the length of each step we may count off the number of steps and compute the overall distance. Ditto for time. Elapsed time divided by number of steps gives time per step. I’m around allegretto/allegro time (~120 steps a minute over which I cover 100 m).
The act of counting is really just a finite number of additions of
1 to arrive at a total count. Bring on the variable,
count, which by the above, says what it represents. The number of items counted.
Counting generally starts from a position of neutrality; that is from a point that has no value that may affect the outcome. In arithmetic we call this the additive identity and its value is 0.
If we construct a sequence of additions,
0 + 1 + 1 + 1 + 1 + 1 + 1 + 1
with the first term set to zero, the final outcome will be the same as when that term is not included.
What we see above is counting, so
count would be the logical variable to reference its present value.
A variable name
nums is very suggestive of a list of numbers by the plurality inferred. One with the name
number will infer singularity. This is what is meant by semantic naming convention; we give concise and explicit meaning to our variable names.
count implies a number, as we’ve discussed, but
number does not imply a count. It’s just number plucked out of somewhere. We get that meaning from its name.
Now given a list of numbers at random, this exercise expects us to count the number of them that are divisible by 10. We start with a
count of zero, as discussed, and then iterate over the list, dividing each by 10 and seeing if there is a remainder or not. If not, we add
1 to our
From here one expects you’ll do smashingly on the exercise, and have some food for thought to carry forward. Happy coding!
In case you were wondering, the number that we ADD to a number that gives us the additive identity is called the additive inverse. Can you guess what it is?
Hint: Above we have a count of
7. What number will take us back to zero if we add it?