usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code for Listing Even Numbers in Python



What are Even Numbers?

Hello pupils, what are even numbers?
Answer:
Even numbers are numbers that are divisible by 2.

They include:

2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, ...

Well then, let's see how we can write a programming code to make our computer list a set of even numbers in the Python language, between a given range of values.

Create a new Python Class File; call it Arithmetic.py.
Create a new Python Module File; call it evenNumbers.py.

Type out the adjoining Python code that lists even numbeers.
We will see what each significant part does as we go along.


How to run Python Codes

Run the code from the cmd shell with the command: cd ~/Documents/usingMaths -- to navigate to the folder where you saved your files;
python Arithmetic.pl









<< PreviousNext >>