The basics of Python
We will cover the basics of Python programming by starting with a simple egg-counting problem.
There are less than 2,000 eggs in a big basket. Let’s say that we take the eggs out in groups of two each time so that one egg is left in the basket at the end. Here, we have the following:
- If a group of 3 is used, 0 are left.
- If a group of 4 is used, 1 is left.
- If a group of 5 is used, 4 are left.
- If a group of 6 is used, 3 are left.
- If a group of 7 is used, 0 are left.
- If a group of 8 is used, 1 is left.
- If a group of 9 is used, 0 are left.
So, how many eggs are in the bucket?
Let’s look at a solution to this problem using Python programming:
for i in range (1, 2001, 2): if ( ((i % 3) == 0) and ((i % 4) == 1) and ((i % 5) == 4) and ((i % 6) == 3) and ((i % 7) == 0) and ((i % 8) == 1) and ((i % 9) == 0) ): print("Total...