Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a dot after an integer mean in python?

Tags:

python

I am looking at this line of python code (which seems to run properly):

import numpy as np yl = 300 + 63*np.exp(-x/35.) 

What is the dot doing after the 35? what does it do? Is it a signal to python that 35 is a float and not an integer? I have not seen this before. Thanks!

like image 461
bernie2436 Avatar asked Oct 20 '14 23:10

bernie2436


People also ask

What does a dot mean in Python?

Dot notation indicates that you're accessing data or behaviors for a particular object type. When you use dot notation, you indicate to Python that you want to either run a particular operation on, or to access a particular property of, an object type.

Why do we put dots after numbers?

It's a decimal point. Alpha explicitly shows it to designate that it's an inexact number.

What is dot notation in coding?

What is the Dot Notation? In simple words, the dot (.) notation is a way to access the attribute and methods of each method of instances of different object classes. It is usually preceded by the object instance while the right end of the dot notation contains the attributes and methods.

What does C followed by a dot mean?

The trailing dot makes the literal a floating point (double) literal, instead of an integer one. Follow this answer to receive notifications. answered Jan 31, 2013 at 13:19. Martin v.


1 Answers

This is easy to test, and you're right. The dot signals a float.

$ python >>> 1. 1.0 >>> type(1.) <type 'float'> 
like image 72
Tim Zimmermann Avatar answered Sep 29 '22 11:09

Tim Zimmermann