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,
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.
y are called variables.
We can check the data type of a variable by using the
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'>