More Variables: Floats

Attention: Our videos have subtitles in all partner languages. You can switch on subtitles in the youtube player by clicking the gear wheel and selecting your preferred language.

This video introduces variable type float and explains how it is used. Did you know the inability of computers to represent some numbers exactly? It's called the rounding error, and we will teach you how to deal with it, by using the rounding function to your advantage. We will help you understand floats and make operations with them. We will teach you to make comments on your code, allowing you to remember every step and for others to better follow up on your ideas

Mathematical operations with floats
1) Define a variable number1 with the value 12.5 and a variable number2 with the value 6.3. 2) Define a variable sum which contains the sum of number1 and number2 by adding them to each other 3) Print the sum
Solution
 number1 = 12.5 # Define two decimal numbers
number2 = 6.3

sum = number1 + number2 # Define a sum variable and add number1 and number2

print(sum) # Print the sum