Category Archives: Beginner


What is a boolean? A boolean is a variable that is either True or False. We say the datatype of a variable can be booelan. You can think of it like a light switch, its either on or off. Note: A bit is the smallest unit in a computer. Its either 0 or 1, True […]


Variables in Python can hold text and numbers. For example:

The variable names are on the left and the values on the right. Once a variable is assigned, it can be used in other places of the program. Related Course: In the example above, we have three variables: x, price and word. Note: Variables […]

Global variables

What is the difference between global and local variables? A global variable can be accessed anywhere in code. A local variable can only be used in a specific code block. Related course: global variable example We say the scope is global, it can be used in any function or location throughout the code. In the […]


A tuple is a collection that cannot be modified. Variables can be of the datatype tuple. A tuple is defined using parenthesis. If you want to change the data during program execution, use a list instead of a tuple. Related Courses Example A tuple with one item ( a comma is needed in the end […]


A dictionary in Python is a one to one mapping. Every key points to a value, separated by a colon (:). A dictionary is defined using curly brackets. The value left of the colon is called the key, the value right of the colon is called the value. Every (key,value) pair is separated by a […]


A list is a collection of objects Everything in Python is an object. These objects in a list are numbers in most cases. Lists can also contain text (strings) or both. Note: Lists can have zero or more elements (empty lists are possible).   Related Course: Lists Example A list is defined using square brackets. […]

List comprehensions

What is list comprehension? List comprehensions are an easy way to create lists. Its much easier to write a one liner than it is to write a for loop, just for creating a list. This one liner is called a list comprehension. Related Course: Example Assume we want to create a list containing 100 numbers. […]

For loops

Do you want to repeat code blocks? To repeat code, the for keyword can be used. Sometimes you need to execute a block of code more than once, for loops solve that problem. We specify the start and end of the loop using the function range(min,max). Related Course: Example To execute a line of code […]

While loop

Unsure how many times to repeat code? Python has the while keyword.¬†Unlike the for loop which tests the condition first, the while loop execute the code first. Sometimes we don’t know how long sometimes will take. A theoretical program could be (pseudocode):

which keeps executing the code block until the condition is true. Related […]


If you want to reuse code, you can use a function. This prevents you from writing the same thing over and over again. A function has a unique distinct name in the program. Once you call a function it will execute one or more lines of codes, which we will call a code block. Related […]