python-ecology-lesson
python-ecology-lesson copied to clipboard
More explanation of modulo
The episode Short Introduction to Programming in Python notes that
We can perform mathematical calculations in Python using the basic operators +, -, /, *, %:
I don't think most people would consider modulo to be a basic operator. I would recommend some more explanation of what modulo does.
I don't think most people would consider
moduloto be a basic operator.
I agree. Would dropping it here be a reasonable alternative to explaining it?
Either way would work from my perspective. It could be useful to know, so it may be worth introducing. However, that may make this lesson longer so I'm fine dropping it as well.
There is a good example which shows either both of things which I miss here: the if/else statement and the example for modulo:
There is one common use for the Modulo Operator: to find even or odd numbers eg in a range 1 to 10:
for number in range(1, 10):
if(number % 2 != 0):
print(number)
The lesson shows the boolean type but no example for the usage. If/else condition would be helpful to introduce at this point. Thus, both topics are great to include here.
I would suggest to add the example of finding even or odd numbers where we introduced a list.
https://datacarpentry.org/python-ecology-lesson/01-short-introduction-to-Python/#lists