Getting started

Python is a programming language with a clean syntax that is easy to learn. Python programs can be run under all desktop computers.  It used in many application domains including: …

Exercise 2: Variables

Python supports different type of variables such as whole numbers, floating point numbers and text.  You do not need to specify the type of variable, you can simply assign any…

Exercise 3: Keyboard input

In Python and many other programming languages you can get user input. Do not worry, you do not need to write a keyboard driver. In Python the input() function will…

Exercise 4: Conditions

A program sometimes may have to make choices.  These choices can execute different code depending on certain condition. In Python the if statement is used for conditional execution. The if…

Exercise 5: For Loops

Programs sometimes need to repeat actions. To repeat actions we can use a for loop. In the exercise below we will repeat actions on every item of a list. The…

Exercise 6: While loop

A while loop repeats code until the condition is met. Unlike for loops, the number of iterations in it may be unknown.  A while loop always consists of a condition…

Exercise 7: Functions

To group sets of code you can use functions. Functions are small parts of repeatable code. A function accepts parameters. In the example below we have parameter x and y….