Python learning notes (arange and linspace functions), arangelinspace
The matplotlib module is mentioned in the previous article, which involves the numpy module scientific counting.
Here we summarize the two array generation functions arange and linspace:
1 #! /Usr/bin/env python 2 #-*-coding: utf_8-*-3 4 import numpy 5 6 7 print numpy. arange (1,100, 2) 8 # start value of the first parameter, end value of the second parameter (not included), step size of the third parameter (interval between each element) 9 print numpy. linspace (1,100, 2) 10 # start value of the first parameter, end value of the second parameter (including by default), number of elements of the third parameter 11 print numpy. linspace (1,100, 2, endpoint = False) 12 print numpy. linspace (1, 99, 2, endpoint = True) 13 # Whether the EndPoint attribute setting includes the end value
Running result