A number is a data type.

We want to say that x is a number. It can take a set of values (for example 1, 10, 42, -100, ) and we can apply operations on it (we can double it for example) or with it (we can add it with another number y).

To write this in python:

x = 5

Now we can see the value of x by:


A practical example: we have 2 numbers, and we want to perform fast operations with them.

x = 2
y = 3
x + y	# add
x * y # multiply
x ** y # x to the power of y

The results should be 5, 6 and 8.

The # is used to mark the rest of the text of that line as a comment.

As you can see, python instructions do not end with semicolumn (;) as in other languages, and the instructions are written on different lines.

x and y are called variables.

We can check the data type of a variable by using the type keyword:

x = 2
x # the computer displays 2
type(x) # computer: <class 'int'>

int is the truncated form of integer which is the set of integer numbers. We can also use rational numbers:

almost_pi = 3.14
type(almost_pi) # computer answer: <class 'float'>