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!
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.
It's a decimal point. Alpha explicitly shows it to designate that it's an inexact number.
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.
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.
This is easy to test, and you're right. The dot signals a float.
$ python >>> 1. 1.0 >>> type(1.) <type 'float'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With