In this section you will find following topics:

  • Float and integer data structures
  • Basic mathematic operations
  • Define variables

int (signed integers) − They are often called just integers or ints, are positive or negative whole numbers with no decimal point.






float (floating point real values) − Also called floats, they represent real numbers and are written with a decimal point dividing the integer and fractional parts. Floats may also be in scientific notation, with E or e indicating the power of 10 (2.5e2 = 2.5 x 102 = 250).





Python Arithmetic Operators
+ Adds two values together 5 + 2 = 7
Subtracts the right operand from the left operand 5 – 2 = 3
* Multiplies the right operand by the left operand 5 * 2 = 10
/ Divides the left operand by the right operand 5 / 2 = 2.5
% Divides the left operand by the right operand and            returns the remainder 5 % 2 = 1
** Calculates the exponential value of the right operand by the left operand 5 ** 2 = 25
// Performs integer division, in which the left operand is divided by the right operand and only the whole number is returned (also called floor division) 5 // 2 = 2

As we know variables from previous chapter, we use them for some mathematic operations too. I will show you different examples about working with variables during mathematic operations.

As you see in table 1, it multiplies left operand by right operand. To change value of i variable, reassign a new value.

Now, let’s try to solve a basic equation and find the value of c variable, after defining them python will calculate the value automatically.

Be carefull when assigning variables:

  • Variable names can not have a number as first letter
  • If variable names are strings, there should not be any spaces
  • Following symbols can not be used within a variable, only “_” is allowed: :'”,<>/?|\()!@#$%^&*~-+
  • Modules, variables,methods pre-defined in Python can not be used as user variables.

Another feature in Python is you can interchange assigned variables. Check this example:

We can increase or decrease the value of a variable.
Continue to Read