eolas/neuron/f2b582e1-cb67-4c06-b6ad-a3e7d0a4f307/Numbers_in_Python.md
2024-11-16 16:29:27 +00:00

606 B

tags
python
data-types

Numbers in Python

Distinguishing int and float

  • In Python we have floats and integers and we can coerce one into the other
  • A // as an operator means float division. This obviously provides greater precision than int division /.
  • There is no increment (++) or decrement (--) operator in Python
# Integers and floats
count = 1
print(count)
# 1
print(type(count))
# <class 'int'>

exchange_rate = 1.83
print(exchange_rate)
# 1.83
print(type(exchange_rate))
# <class 'float'>

print(float(count))
# 1.0

print(int(exchange_rate))
# 1