CoCalc Public FilesList of even numbers in a range of 1 to 100 including 100.ipynbOpen with one click!
Author: MIRALIA MOREAU
Views : 59
Compute Environment: Ubuntu 20.04 (Default)

I will Use list comprehension to create a list containing all even numbers from 1 to 100 (including 100). According to the definition of even numbers, they are numbers that can be re-witting as 2k where k is an integer. Moreover, all even numbers are divisible by 2.

In [2]:
[i for i in range(1,101) if i%2==0]
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]

As the result reveals all the even numbers from 1 to 100 including 100, all this number is divisible by 2, and they can also be written as 2k.