Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NumPy Pseudo Real World Assignment For this assignment you'll be determining the winner of a card game using NumPy arrays!. Here's how the card game

image text in transcribed

NumPy Pseudo Real World Assignment For this assignment you'll be determining the winner of a card game using NumPy arrays!. Here's how the card game works: - 36 cards are dealt to 6 players ( 6 cards each) - The cards each have a unique number between 1 and 36 - For player 1 , the first card is considered positive and the rest negative - For player 2, the second card is considered positive and the rest negative - For player 3 , the third card is considered positive and the rest negative - For player 4, the fourth card is considered positive and the rest negative - For player 5 , the fifth card is considered positive and the rest negative - For player 6 , the sixth card is considered positive and the rest negative - Add up all player cards - Whichever player has the highest score, wins the game Directions 1. Create a 1-dimensional NumPy array with the numbers 1-36 in it (use np.arange for an easy way to do this) 2. Shuffle the array (use np.random.shuffle) 3. Reshape the array to 66 4. You now have an array showing the cards dealt to the players 5. You now need to get the positive diagonal numbers into a new array by multiplying your dealt cards array by an identity matrix 6. You now have to flip the numbers that are not on the diagonal to negative: 1. You need to create a 66 identity matrix and subtract a 66 array of all 1s from it. You should end up with an array that is zeros on the diagonal and -1s everywhere else 2. Create a new array by multiplying your array of negative 1s and your array of dealt cards. You should end up with an array that is os on the diagonal and negative numbers elsewhere. 7. Using your array of positive numbers and your array of negative numbers, combine them into a new array of all the dealt cards. It should now have the correct sign on all dealt cards 8. create a 61 array by summing all the rows of this array. This new array is your player score 9. Determine the maximum score and which player got that score(np.max and np.argmax) 10. Print the winner and their score (don't forget that the array position is zero indexed. I don't want player 0 to win) Submit your working program. This is worth 15 points

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

=+7 How has the COVID-19 pandemic impacted the operations of IHRM?

Answered: 1 week ago