Python Making an arrey of a zipped list, Python

  • Thread starter Thread starter MaxManus
  • Start date Start date
  • Tags Tags
    List Python
Click For Summary
The discussion centers on creating an array from a list in Python, clarifying that Python uses lists rather than traditional arrays. The user seeks a detailed explanation of how to implement this. A function is defined to calculate a Gaussian distribution, and an array of x-values is generated using `linspace`. The code snippet demonstrates how to compute corresponding y-values using the defined function and store them in a zero-initialized array. The final output formats the x and y values for display. The conversation emphasizes the distinction between lists and arrays in Python, highlighting the use of libraries like SciPy for array operations.
MaxManus
Messages
268
Reaction score
1
How do you make an arrey out of this list?

for X, H in zip(xarrey,harrey):
print "%.2f %.5f" % (X,H)
 
Technology news on Phys.org
Can you give me a more detailed explanation? I don't know what list you're talking about, or what you mean by "making an array" out it. Python doesn't have "arrays," it has lists.

- Warren
 
from scitools.all import *

def h(x):
return (1/(sqrt(2*pi)))*e**-(0.5*x**2)

xarray = linspace(-4,4,10)
x = xarray
harrey = zeros(len(xarrey))

for i in xrange(len(xarray)):
harrey = h(x)

for X, H in zip(xarray,harray):
print "%.2f %.5f" % (X,H)
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 11 ·
Replies
11
Views
939
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
1
Views
2K
  • · Replies 43 ·
2
Replies
43
Views
4K