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...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
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)...
Laboratory 4: Black Jack! Java API ArrayList Lab 04 Documentation Included matrix package "external" documentation Included...
Laboratory 4: Black Jack! Java API ArrayList Lab 04 Documentation Included matrix package "external" documentation Included Download Lab04.zip for all of the additional supporting files that you will need to compile and run. Extract the files into your working directory You can find the rules of blackjack all over the Internet. To get an idea of what you are trying to accomplish in this lab, I’ll demonstrate the final solution. The dealer stands on all 17s. Doubling after splitting is...
Do the TODOs in SongFileAccessor.java. It inherits from FileAccessor class. TODO 1: Implement the processLine method....
Do the TODOs in SongFileAccessor.java. It inherits from FileAccessor class. TODO 1: Implement the processLine method. When the text file is processed, each line of text will be passed to processLine . Each line contains 4 fields: title, album, artist, and play time. The album field is optional. Each field is separated by a comma. TODO 2: Implement the songToCSVString method. This method takes a Song object as a parameter and returns a String which is the csv representation of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT