ANSWERS #2
Import numpy - correct answer import numpy as np
How to print out multiple stuff on one line - correct answer Use commas to separate the
printed statements
Print("Some string", a_variable)
How to print multiple stuff and then print out space beneath the printed statement -
correct answer Use '\n'
Print("One Dimensional Array", x1, '\n')
How to separate stuff from a printed statement into different paragraphs - correct
answer Use sep='\n'
Print("One Dimensional Array", x1, sep='\n')
Two dimensional array - correct answer my_array= np.array([[3,4,5,6],[4,5,6,-9]])
How to return the number of dimensions an array has - correct answer x1.ndim
Return the number of elements a in each dimension of an array - correct answer
x1.shape
Return the total number of elements across all dimensions of an array - correct answer
x1.size
How to tell the data types of elements in an array - correct answer float_array.dtype
Return every third element of an array - correct answer my_array[::3]
Return every other element, starting with the first element - correct answer
my_array[1::2]
How to reverse an array - correct answer numeric_array[::-1]
How to add value to dictionary - correct answer No brackets on other side
University_info['country'] = 'United States'
University_info
Function rule - correct answer Always return, don't print
, How to sort with numpy - correct answer np.sort()
For multidimensional arrays, specify axis
Np.sort(my_array, axis=0)
0 sorts columns, and 1 sorts rows
Nd_player_weights.sort() would sort the original values
How to split up array according to your specs - correct answer np.split(my_array,
[3,5,8])
Will split up values with indexes 0-2, then 3-4, then 5-7, then 8 beyond
How to split an array into equal parts - correct answer np.array_split(my_array, 6)
NO BRACKETS
Six arrays with equal parts. It returns a list with the specified number of arrays inside of
it
Np.hsplit() - correct answer split_1, split_2 = np.hsplit(employee_salaries_grid,
indices_or_sections=[3])
Print("First Split", split_1, sep='\n')
Print("Second Split", split_2, sep='\n')
OUT:
First Split
[[ 101442. 94122. 101592.]
[ 87006. 102228. 84054.]
[ 90024. 82614. 48078.]
[ 76266. 68616. 62820.]]
Second Split
[[ 110064. 50436. 103350. 93354. 84054.]
[ 91272. 111492. 95484. 114846. 63480.]
[ 72510. 48078. 110064. 110064. 42108.]
[ 128970. 48078. 89148. 101712. 70092.]]
Np.vsplit() - correct answer split_1, split_2, split_3 = np.vsplit(employee_salaries_grid,
[1, 3])
Print(split_1, split_2, split_3, sep='\n\n')
OUT:
[[ 101442. 94122. 101592. 110064. 50436. 103350. 93354. 84054.]]
[[ 87006. 102228. 84054. 91272. 111492. 95484. 114846. 63480.]
[ 90024. 82614. 48078. 72510. 48078. 110064. 110064. 42108.]]