Question

Create a 2D numpy array that contains values (4, 3, 1, 33, 21) in the first...

  1. Create a 2D numpy array that contains values (4, 3, 1, 33, 21) in the first row values (67, 27, 89, 34, 67) in the second row and values (60, 99, 89, 12, 43) in the third row
    Your code should print the following:

    • [[ 4 3 1 33 21]
      [67 27 89 34 67]
      [60 99 89 12 43]]
  2. Write code that prints values [34, 67] [12, 43].
    You must use the colon : based slicing approach to complete this task.
    Your code should print the following:

    • [[34 67]
      [12 43]]

Homework Answers

Answer #1

Source Code:

Output:

Code in text format (See above image of code for indentation):

#import numpy module
import numpy as np

#create a list of lists
values=[[4,3,1,33,21],[67,27,89,34,67],[60, 99, 89, 12, 43]]
#create 2D numpy array
ar=np.array(values)
#print array
print("2D Array is:")
print(ar)
print()
#print values using slicing
print(ar[1:3,3:5])

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a 1D numpy array that contains int values (4, 3, 1, 33, 21, 67, 27,...
Create a 1D numpy array that contains int values (4, 3, 1, 33, 21, 67, 27, 89, 34, 67, 99, 89, 12, 43). Hint: You can put these values in a python list and start from there. Write code that prints values (67, 27, 89, 34). You must use the colon : based slicing approach to complete this task. Your code should print the following: [67 27 89 34] Write code to print the average (mean) and median values for...
Create a 1D numpy array that stores values (4, 3, 1, 33, 21, 67, 27, 89,...
Create a 1D numpy array that stores values (4, 3, 1, 33, 21, 67, 27, 89, 34, 67, 99, 89, 12, 43) AS STRING VALUES. Hint: Explore using dtype Your code should print the following: ['4' '3' '1' '33' '21' '67' '27' '89' '34' '67' '99' '89' '12' '43']
Question 2: Write a C program that read 100 integers from the attached file (integers.txt) into...
Question 2: Write a C program that read 100 integers from the attached file (integers.txt) into an array and copy the integers from the array into a Binary Search Tree (BST). The program prints out the following: The number of comparisons made to search for a given integer in the BST And The number of comparisons made to search for the same integer in the array Question 3 Run the program developed in Question 2 ten times. The given values...
Student Grades Student Test Grade 1 76 62 2 84 90 3 79 68 4 88...
Student Grades Student Test Grade 1 76 62 2 84 90 3 79 68 4 88 84 5 76 58 6 66 79 7 75 73 8 94 93 9 66 65 10 92 86 11 80 53 12 87 83 13 86 49 14 63 72 15 92 87 16 75 89 17 69 81 18 92 94 19 79 78 20 60 71 21 68 84 22 71 74 23 61 74 24 68 54 25 76 97...
Pinky and The Brain are great friends. They like to play games with numbers. This time,...
Pinky and The Brain are great friends. They like to play games with numbers. This time, Pinky has given The Brain a list of numbers and given him the task of determining if it is possible to choose a subset of them such that they sum is equal to another given number. Build an algorithm using dynamic programming to help The Brain with his problem. INPUT The first line corresponds to N, the amount of numbers given by Pinky The...
Taxpayer Form 1 Form 2 Form 3 Form 4 1 109 115 126 120 2 98...
Taxpayer Form 1 Form 2 Form 3 Form 4 1 109 115 126 120 2 98 103 107 108 3 29 27 53 38 4 93 95 103 109 5 62 65 67 64 6 103 107 111 128 7 83 82 101 116 8 122 119 141 143 9 92 101 105 108 10 107 113 127 113 11 103 111 111 108 12 54 64 67 62 13 141 145 142 160 14 92 94 95 102 15...
And need to be writing in C++ language Programm need to start with   #include<fstream> Prepare a...
And need to be writing in C++ language Programm need to start with   #include<fstream> Prepare a text file data_in.txt with the following information (highlight the piece of text below with numbers and copy it to a text file): 54, 70, 75, 63, 17, 59, 87, 16, 93, 81, 60, 67, 90, 53, 88, 9, 61, 8, 96, 98, 12, 34, 66, 76, 38, 55, 58, 27, 92, 45, 41, 4, 20, 22, 69, 77, 86, 35, 19, 32, 49, 15,...
This dataset contains consumer responses indicating the number of times they had to send their product...
This dataset contains consumer responses indicating the number of times they had to send their product for repair and their satisfaction with the repair process. Create a graph which can be used to visually demonstrate the relationship between the two columns of data. Ensure that the chart is professional with appropriate titles, axis labels, etc. Note any observations you see in your visualization (type these as sentences directly into an Excel cell(s)). Sample Satisfaction Rating Repair Requests 1 63% 13...
The vice president of the student organization has asked you to create an estimate of the...
The vice president of the student organization has asked you to create an estimate of the proportion of students who have attained more than 60 credit hours. You ask her what level of confidence she wants to have in the estimate and she says that she would like to be 90% confident in the proportion estimate. Create the confidence interval using the sample data. Write a sentence or two to communicate the results to her. Student More than 60 credit...
Using the accompanying Student Grades​ data, construct a scatter chart for midterm versus final exam grades...
Using the accompanying Student Grades​ data, construct a scatter chart for midterm versus final exam grades and add a linear trendline. What is the​ model? If a student scores 7878 on the​ midterm, what would you predict her grade on the final exam to​ be? Student Midterm Final Exam 1 75 64 2 85 91 3 80 68 4 88 83 5 76 60 6 67 80 7 78 74 8 95 94 9 67 61 10 93 87 11...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT