 # Python for Beginners – Basic Codes to get you Started

Python is the backbone of Artificial Intelligence and learning python is the gateway to unlocking its capabilities. While it may all sound confusing and foreign at first, the key, as to every other difficult problems, is to actually try and get started. So here we have the simple run codes that you have to understand in order to learn python.

## Print

To actually get Python to run any code you write on your py script, use print( ), and python will run what is between the brackets. For example, if you wish to do a simple calculation such as 1+2, simply key in as such print(1+2). This also works for multiplication, division etc. I.e print(10/2) which will run 10 divide by 2 or print(1*2) which will run 1 multiple by 2 and so on.

## Exponentiation **

To do a square of formula, we use the exponentiation code which is 2 asterisk. One asterisk is for multiplication and two asterisk is for exponentiation. The code will use the number on it’s left and run it to the square of the number on the right. For example,

print(2**3) will give you 8, which works out to be 2 x 2 x 2 = 8.

print(4**4) will give you 256 which works out to be 4 x 4 x 4 x 4 = 256

## Variable and Strings

In Python, you are able to assign a variable to a code. Think of it as naming a string of codes, so you don’t have to retype the code each time you want to use it again.

For example, you wish to find out how much interest can you get based on your annual pay. You can first name your annual pay as a variable.

annual_pay= 2000*12
ocbc_interest= 1.1
ocbc_result=annual_pay*ocbc_interest
print(ocbc_result)

you can also use Variable on text, also known as strings in Python. However, for anything that is related to strings (text), you would have to add a single or double quotes, For example:

x = “awesome”
print(“The Collective Intelligence is ” + x)

The Collective Intelligence is awesome

## Types – Integer, Float, String, Boolean

So aside from text also known as Strings (str) in Python, there are also other types of classification for different types of codes.

For whole numbers, it is known as Integer or int in Python.

For numbers with decimal places, it is called a float.

Boolean are codes that represent logical value such as True or False