I recently started to refresh my python skills that I have been never really working on since I finished university 16 years ago. In my work life I have never been in contact with the python language. So I would like to embrace this language again. In order to do that I have found some problems that I am currently working on which I would like to finish soon:
Problem 1:
0.) Create a numpy array (6x6, randomly) with whole count numbers ranging from -10 to 10. After that complete the following matrix operations:
My idea:
import numpy as np M = np.random.randint(low=-10, high=10, size=(6, 6)) print(M)
a.) Cut the first row from the matrix
my idea:
first_row = M[0:1] print(first_row)
b.) Double the value of the elements from the 5th row by 2
my idea
5th_row = M[4:5] print(5th_row*2)
c.) Cut all odd columns (the sum of the column) from the 6x6 array
I heard that this can be done in one line. And I have now idea how to get the columns and display them as a matrix with the column_stack command...
d.) Cut a random 3x3 block from the 6x6 array
Again I cant even start with this one...
e.) Set all negative numbers in the 6x6 array to zero
I guess i can use if loops for each element, but i do have no idea how to filter the negative numbers from the positive ones and set the negative numbers zero
f.) Cut all even rows (the sum of the rows) from the 6x6 array
Again here I have big troubles tackling this problem...
Problem 2:
0.) I have a resonance curve as stated here:
A(eta,A_s,D)=A_s/(root[(1-eta²)²+(2etaD)²])
a.) For A_s = 1.0 I want to display a 2d-parametric plot with eta (x-axis) in a range between [0, 3] and the parameter D for [0.0.5,1.0,3.0]
It would be awesome if you could contribute some solutions to the mentioned problems.
best regards
Greta