Fill in the gap in the answer box with an expression that yields the "centre portion" of the array data, defined as all the data except the left and right columns and the top and bottom rows. The code should thus print [[20 30]] Notes: • Your code will be tested with other data arays, which may have different numbers of rows or columns. • You may assume data has at least 3 rows and at least 3 columns Answer: 1 import numpy as np 2 data = np.array([[1, 2, 3, 4], [10, 20, зе, 40], [100, 200, 300, 400]]) 3 4 5 selection = 6 |print(selection)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Fill in the gap in the answer box with an expression that yields the "centre portion" of the
array data, defined as all the data except the left and right columns and the top and
bottom rows.
The code should thus print
[[20 30]]
Notes:
• Your code will be tested with other data arrays, which may have different numbers of
rows or columns.
• You may assume data has at least 3 rows and at least 3 columns
Answer:
1 import numpy as np
2 data = np.array([[1, 2, 3, 4],
[10, 20, зе, 40],
[180, 200, 300, 400]])
3
4
5 selection =
6 |print(selecton)
Fill in the gap in the answer box with an expression that yields the rightmost column of
the array data as a 1D array but skipping every second row.
The code should thus print
[ 4 40 -4]
Notes:
• Your expression will be tested with other values of data.
Answer:
1 import numpy as np
2 data - np.array([[1, 2, 3, 4],
[100, 200, зее, 4ө0],
[10, 20, зе, 40],
[1000, 2000, 3000, 4000],
[-1, -2, -3, -4]
1)
4.
6
7
8 selection -
9 print(selection)
Transcribed Image Text:Fill in the gap in the answer box with an expression that yields the "centre portion" of the array data, defined as all the data except the left and right columns and the top and bottom rows. The code should thus print [[20 30]] Notes: • Your code will be tested with other data arrays, which may have different numbers of rows or columns. • You may assume data has at least 3 rows and at least 3 columns Answer: 1 import numpy as np 2 data = np.array([[1, 2, 3, 4], [10, 20, зе, 40], [180, 200, 300, 400]]) 3 4 5 selection = 6 |print(selecton) Fill in the gap in the answer box with an expression that yields the rightmost column of the array data as a 1D array but skipping every second row. The code should thus print [ 4 40 -4] Notes: • Your expression will be tested with other values of data. Answer: 1 import numpy as np 2 data - np.array([[1, 2, 3, 4], [100, 200, зее, 4ө0], [10, 20, зе, 40], [1000, 2000, 3000, 4000], [-1, -2, -3, -4] 1) 4. 6 7 8 selection - 9 print(selection)
Fill in the gap in the answer box with an expression that yields a 2D numpy array that
represents a 2x2 array made from the elements in the top left corner of data.
The code should thus print
[[ 1 2]
[10 20]]
Notes:
• Your code will be tested with other data arrays, which may have different numbers of
rows or columns.
• You may assume data has at least two rows and at least two columns.
Answer:
1 import numpy as np
data = np.array([[1, 2, 3, 4),
[10, 20, 30, 40],
[100, 200, зеө, 400]])
2
4
5 selection
6 print(selection)
Transcribed Image Text:Fill in the gap in the answer box with an expression that yields a 2D numpy array that represents a 2x2 array made from the elements in the top left corner of data. The code should thus print [[ 1 2] [10 20]] Notes: • Your code will be tested with other data arrays, which may have different numbers of rows or columns. • You may assume data has at least two rows and at least two columns. Answer: 1 import numpy as np data = np.array([[1, 2, 3, 4), [10, 20, 30, 40], [100, 200, зеө, 400]]) 2 4 5 selection 6 print(selection)
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY