Marian13
Marian13

Reputation: 9288

Python: What does a dot before an integer mean?

I was reading some Python code:

math.ceil(.1) + math.floor(.1)

and have encountered the following notation - .1.

Could someone explain what does it mean?

Thanks in advance.

Upvotes: 0

Views: 391

Answers (3)

ti7
ti7

Reputation: 18826

The integer is a float (decimal) value

>>> .1
0.1
>>> 1
1

As Shashank V's answer notes, one can can check the type of an object by calling type() on it!

>>> type(.1)
<class 'float'>
>>> a = .1
>>> type(a)
<class 'float'>

Upvotes: 4

Shashank V
Shashank V

Reputation: 11213

It's a float. .1 represent the decimal value 0.1

>>> type(.1)
<class 'float'>

https://docs.python.org/3/tutorial/floatingpoint.html

Upvotes: 3

ptitpoulpe
ptitpoulpe

Reputation: 694

.1 is a float, it's equivalent to 0.1

Upvotes: 3

Related Questions