Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Numpy file output: Create a Python script that generates a 100x1 array of random numbers between 0 and 1, and writes the array to file.

Numpy file output: Create a Python script that generates a 100x1 array of random numbers between 0 and 1, and writes the array to file. A few hints here:

You can initialize an all-zero array of size 100x1 using the np.zeros module.

After the array is initialized, you can loop over all of the elements of the array using a "for" loop, and replace each zero element in the array with a random number.

The function random.random will generate a random number between 0 and 1. Be sure to import the random package at the beginning of your code (import random) before using the random.random function.

Use the function np.savetxt for saving matrix data to file.

Numpy file input and plotting: Create a Python script that reads in the array that you saved and uses matplotlib to plot the array as a scatterplot. (Hint: use the function np.loadtxt for reading in matrix data from file, similar to that which we used in class in reading in the surface profile data.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

3. The group answers the questions.

Answered: 1 week ago