Q:

Write a NumPy program to create a 11x3 array filled with student information (id, class and name) and shuffle the said array rows starting from 3rd to 9th

0

Write a NumPy program to create a 11x3 array filled with student information (id, class and name) and shuffle the said array rows starting from 3rd to 9th.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
np.random.seed(42) 
student = np.array([['stident_id', 'Class', 'Name'],
              ['01', 'V', 'Debby Pramod'],
              ['02', 'V', 'Artemiy Ellie'],
              ['03', 'V', 'Baptist Kamal'],
              ['04', 'V', 'Lavanya Davide'],
              ['05', 'V', 'Fulton Antwan'],
              ['06', 'V', 'Euanthe Sandeep'],
              ['07', 'V', 'Endzela Sanda'],
              ['08', 'V', 'Victoire Waman'],
              ['09', 'V', 'Briar Nur'],
              ['10', 'V', 'Rose Lykos']]) 
print("Original array:")
print(student)
np.random.shuffle(student[2:8])
print("Shuffle the said array rows starting from 3rd to 9th")
print(student)

Sample Output:

Original array:
[['stident_id' 'Class' 'Name']
 ['01' 'V' 'Debby Pramod']
 ['02' 'V' 'Artemiy Ellie']
 ['03' 'V' 'Baptist Kamal']
 ['04' 'V' 'Lavanya Davide']
 ['05' 'V' 'Fulton Antwan']
 ['06' 'V' 'Euanthe Sandeep']
 ['07' 'V' 'Endzela Sanda']
 ['08' 'V' 'Victoire Waman']
 ['09' 'V' 'Briar Nur']
 ['10' 'V' 'Rose Lykos']]
Shuffle the said array rows starting from 3rd to 9th
[['stident_id' 'Class' 'Name']
 ['01' 'V' 'Debby Pramod']
 ['02' 'V' 'Artemiy Ellie']
 ['03' 'V' 'Baptist Kamal']
 ['07' 'V' 'Endzela Sanda']
 ['04' 'V' 'Lavanya Davide']
 ['06' 'V' 'Euanthe Sandeep']
 ['05' 'V' 'Fulton Antwan']
 ['08' 'V' 'Victoire Waman']
 ['09' 'V' 'Briar Nur']
 ['10' 'V' 'Rose Lykos']]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now