Create each of these scenarios using numpy arrays.

A teacher wants to know the median of each of her classes’ grades on a recent test. She creates a

*5 x 7 array*where each row represents a class and each column represents a set of students.*Sort*the columns. Then,*split*the array vertically and*take the middle column*, which is the set of medians. Print this column.Jason and Damian are playing cards with a deck of 24. Each of the two have 12 cards, and each card is

*random*and is from*1 to 10, inclusive.*Right before they start playing, Tim also wants to join, so they*reshape*their deck so that it’s 8 cards for each of them. Lastly, shuffle the cards.

Recourses:

Code: __https://replit.com/@Shrav816/IntrotoPython-Class21__

Contact Info:

__shravyassathish@gmail.com__ (mentor)

__kingericwu@gmail.com__ (TA)

__felixguo41@gmail.com__ (TA)

import numpy as np

rng = np.random.default_rng()

grades = np.array([rng.integers(50, 100, 7, int, True) for i in range(5)])

grades = np.sort(grades, 0)

np.vsplit(grades, 5)

print(f"Part 1: {grades[2]}\n\n\nPart 2: ")

#rng = np.random.default_rng()

deck = np.array([rng.integers(1, 10, 12, int, True) for i in range(2)])

Jason = deck[0]

Damian = deck[1]

deck = deck.reshape(3, 8)

rng.shuffle(deck, 1)

Jason = deck[0]

Damian = deck[1]

Tim = deck[2]

print(f"Jason's hand is {Jason}, Damian's hand is {Damian}, and Tim's hand is {Tim}")

1.

import random

import numpy as np

scores = [[random.randint(0, 5) for i in range(7)] for j in range(5)]

print(f"{scores}\n")

scores = np.sort(scores, 0)

print(f"{scores}\n")

scores = np.vsplit(scores, 5)

print(scores[2])

2.

import numpy as np

rng = np.random.default_rng()

cards = np.array([rng.integers(1, 10, 12, int, True) for i in range(2)])

print(f"{cards}\n")

cards = cards.reshape(3, 8)

print(f"{cards}\n")

rng.shuffle(cards, 1)

print(f"Jason:{cards[0]}\nDamian:{cards[1]}\nTim:{cards[2]}\n")

import numpy as np

rng = np.random.default_rng()

grades = np.array([rng.integers(50, 100, 7, int, True) for i in range(5)])

grades = np.sort(grades, 0)

np.vsplit(grades, 5)

print(f"Part 1: {grades[2]}\n\n\nPart 2: ")

#rng = np.random.default_rng()

deck = np.array([rng.integers(1, 10, 12, int, True) for i in range(2)])

Jason = deck[0]

Damian = deck[1]

deck = deck.reshape(3, 8)

rng.shuffle(deck, 1)

Jason = deck[0]

Damian = deck[1]

Tim = deck[2]

print(f"Jason's hand is {Jason}, Damian's hand is {Damian}, and Tim's hand is {Tim}")

1.) import numpy as np

grades = np.array([

[32, 7, 100, 85, 79, 12, 91],

[75, 78, 75, 83, 5, 84, 81],

[94, 89, 87, 94, 92, 90, 68],

[34, 75, 76, 72, 80, 78, 81],

[87, 44, 86, 90, 23, 89, 91]

])

sortedGrades = np.sort(grades , axis=0)

medians = np.median(sortedGrades[:, 3])

print(medians)

2.)

deck = np.random.randint(1, 11, size = 24)

np.random.shuffle(deck)

J = deck[:12]

D = deck[12:24]

deck = deck.reshape(3, 8)

np.random.shuffle(deck)

J, D, T = deck

print("Jason's hand: ", J)

print("Damian's hand: ", D)

print("Tim's hand: ", T)