Noticing Even Numbers¶

Write a program that uses a for loop to display all the numbers from 1 to 20, marking those which are even (divisible by two). You should should use modulus for this (% 2). If the remainder is zero, it’s divisible by 2.

This means you’ll need an if statement inside the loop.

Name your file: notice_even.py

# pseudo-code
for whatever...
    if someting with modulus:
        print("something")
    else:
        print("something different")
1
2 <
3
4 <
5
6 <
7
8 <
9
10 <
11
12 <
13
14 <
15
16 <
17
18 <
19
20 <

©2021 Daniel Gallo

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.

Creative Commons License

Adapted for Python from Graham Mitchell’s Programming By Doing