7. Numeric variables

System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP05/TWP05_7_en.rst, line 7)

Bullet list ends without a blank line; unexpected unindent.

  1234.56 + Note that 1.0, even though it has a zero in the decimal part, is a floating point number + Values of type floating point in Python are called float.

7.1. Representation of numeric values

  • Internally, all numbers are represented with the binary system

  • This system only allows the digits 0 or 1

  • Floating point numbers may not have a proper representation

System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP05/TWP05_7_en.rst, line 18)

Bullet list ends without a blank line; unexpected unindent.

  in the binary system + Typing in the interpreter 3 * 0.1 will give us a response of: 0.30000000000000004

Try it here!

Python code: ```python # Declaring an integer variable a = 42 print(a) # Output: 42 print(type(a)) # Output: <class ‘int’>

System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP05/TWP05_7_en.rst, line 28); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP05/TWP05_7_en.rst, line 28); backlink

Inline interpreted text or phrase reference start-string without end-string.

# Declaring a floating point variable b = 1.0 print(b) # Output: 1.0 print(type(b)) # Output: <class ‘float’>

# Operations with numbers x = 3 y = 0.1 print(x * y) # Output: 0.30000000000000004 ```

System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP05/TWP05_7_en.rst, line 40); backlink

Inline literal start-string without end-string.

System Message: WARNING/2 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP05/TWP05_7_en.rst, line 40); backlink

Inline interpreted text or phrase reference start-string without end-string.

You have attempted of activities on this page