Question

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 this array. You code should print the following: 42.07142857142857 for the mean 33.5 for the median

Homework Answers

Answer #1

Source Code:

Output:

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

#import numpy library
import numpy as np

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

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 2D numpy array that contains values (4, 3, 1, 33, 21) in the first...
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]] Write code that prints values [34, 67] [12, 43]. You must use the colon : based slicing approach to complete...
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']
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...
MALE :Student # Gender Height Shoe Age Hand 1 M 67 10 19 R 2 M...
MALE :Student # Gender Height Shoe Age Hand 1 M 67 10 19 R 2 M 74 12 17 R 3 M 72 11.5 19 R 4 M 69 10 35 R 5 M 66 9 18 R 6 M 71 10.5 17 R 7 M 72 10.5 17 R 8 M 66 10 20 R 9 M 67 10 18 R 10 M 71 10.5 24 R 11 M 66 10 21 R 12 M 71 10.5 18 R...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import java.io.*; //This imports input and output (io) classes that we use 3 //to read and write to files. The * is the wildcard that will 4 //make all of the io classes available if I need them 5 //It saves me from having to import each io class separately. 6 /** 7 This program reads numbers from a file, calculates the 8 mean (average)...