Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help, thanks
#1
1. This was my quiz and I need help to understand why the correct answer is A? I chose B Sad

The output of the following code is:
X=np.random.random((10,3))
Xmean=X.mean(axis=0)

A. Generate a 10X3 array and get the means of the columns


B. Generate a 10X3 array and get the means of the rows


C. Generate a 3X10 array and get the means of the columns


D. Generate a 3X10 array and get the means of the rows

2. Changing the values in a slice of an array will change the underlying array.

A. True


B. False

I chose False but correct answer is True. Is A correct answer?

Thank you
Reply
#2
I made an experiment
>>> import numpy as np
>>> X=np.random.random((10,3))
>>> Xmean=X.mean(axis=0)
>>> X
array([[9.62417069e-01, 7.12900873e-01, 7.84239857e-01],
       [3.70667459e-01, 5.91862984e-01, 1.22417329e-01],
       [4.48273079e-01, 2.20115270e-01, 9.76291915e-01],
       [6.34593868e-01, 3.16918159e-01, 3.07018204e-01],
       [8.49735378e-01, 7.98056376e-01, 6.20389038e-01],
       [6.09542477e-01, 4.86588051e-02, 7.21532696e-01],
       [1.47870537e-01, 3.21975558e-01, 5.26807464e-01],
       [8.15975691e-01, 4.16663236e-01, 3.36694600e-01],
       [9.10517902e-01, 1.68949538e-01, 4.64918228e-04],
       [3.46146746e-02, 1.81351751e-01, 4.52962513e-01]])
>>> Xmean
array([0.57842081, 0.37774526, 0.48488185])
Reply
#3
See the examples in the docs Here
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020