Python for Beginners #1 The Basics

Python is a user friendly, object oriented programming language. It was created in 1991 by Guido van Rossum. Python was designed to be easily read and uses simple syntax. This makes Python great for beginners.

Python can be used for:

  • Web Development
  • Data Science
  • Data Analysis
  • Machine Learning

Python Indentation

Indentation is important when coding in python. In most programming languages, C or java, brackets {} are used to separate blocks of code. In Python, indentation is used. A block of code starts with indentation and ends with the first unindented line.

A good rule of thumb is four white spaces.

The example on the left is correct indentation. The example on the right, is Incorrect and will produce a Syntax Error.

Here is a diagram for code block indent structuring.

Python Variables

Variables are used to store data values. There are two types of variables, Fixed (constant) values and variable values. Common data types of variables are Strings, Characters and Integers.

In Python, variables do not need to be declared. Once a variable is defined a value, it is created.

Variables Rules :

  • Variables must start with alpha character or underscore (No numbers)
  • Variables names can only consist of alpha characters, integers and underscores
  • Variables are case sensitive (var , Var , VAR, vAr. These are four different variables.)

Examples of Python variables

x = "Hello"


>>> Hello

Adding variables

A = 5
b = 15
print(A + b)


>>> 20

Defining Multiple Variables

x , y ,z = "Red", "Blue", "Green"


>>> Red Blue Green
Click here for Part Two :Basic operations