Question

In: Computer Science

On python : d. Create a null vector of size 10 but the fifth value which...

On python :

  • d. Create a null vector of size 10 but the fifth value which is 1. - 5 Point
  • e. How to sum a small array faster than np.sum?- 5 Point

Solutions

Expert Solution

The python solutions are provided below:

d.

Solution:

The statements to create a null vector of size 10 with the fifth element as 1 is as follows:

v = np.zeros(10)

v[4] = 1

Explanation:

  • The v represents the vector with 10 null elements.
  • The statement v[4] = 1 represents that the fifth index value of vector is set to 1.

The complete code for testing the statements are provided below:

Screenshot of the code:

Sample Output:

Code To Copy:

#Import the packages.

import numpy as np

#Define the vector of 10.

v = np.zeros(10)

#Display the vector.

print(v)

#Display the fifth value.

print("Update fifth value to 1")

#Update the fifth value of vector as 1.

v[4] = 1

#Display the updated vector v.

print(v)

e.

Solution:

  • The difference between the sum and the np.sum is that the np.sum are more useful and faster to use in the case of arrays.
  • While Python sum() is useful for lists.
  • So, it depends upon the defined case, if there is arrays then it is better to use the np.sum.
  • But if it is a list, then it is better to use the sum().

Related Solutions

D. 1. A sample of size 16 is used in testing the null hypothesis that μ...
D. 1. A sample of size 16 is used in testing the null hypothesis that μ > 100.  The sample results indicate that = 96 and s = 4.  Test the null hypothesis using a significance level of .05.        2.  What does the significance level tell us? That is, precisely what is it that has a probability of less than .05?  Be specific.
Create a code for A vector for forecasting and the value of alpha and provides an...
Create a code for A vector for forecasting and the value of alpha and provides an exponential smoothing forecast for the given dataset within R.
In Python write a function with prototype “def dictsort(d):” which will return a list of key-value...
In Python write a function with prototype “def dictsort(d):” which will return a list of key-value pairs of the dictionary as tuples (key, value), reverse sorted by value (highest first) and where multiple keys with the same value appear alphabetically (lowest first).
10. In ANOVA, if the null hypothesis is true, the Fobt value will be _____.               ...
10. In ANOVA, if the null hypothesis is true, the Fobt value will be _____.                a.            0                b.            1                c.            a negative number                d.            a high number 11.       The null hypothesis for the one-way 2 is _____. a.            expected frequencies equal observed frequencies b.            expected frequencies are equal to each other c.            observed frequencies are equal to each other d.            fos ? fes Imagine that a general estimate of elementary-school students who have lice is 8%....
Create a vector of student records (minimum 15+ records) which is unsorted (For Vector, refer to...
Create a vector of student records (minimum 15+ records) which is unsorted (For Vector, refer to Chapter 7.11 or 17.3, or you may use Array of structures) - You should read student records from a file into the vector in C++ or in Java program. - Display the unsorted 10+ student records (entire record, not just ID) and associated test scores. - Each Student record should include Student ID, Name, GPA, Student Address, and a pointer which points to (10+)...
C++ Create a vector of student records (minimum 15+ records) which is unsorted (For Vector, refer...
C++ Create a vector of student records (minimum 15+ records) which is unsorted (For Vector, refer to Chapter 7.11 or 17.3, or you may use Array of structures) - You should read student records from a file into the vector in C++ or in Java program. - Display the unsorted 10+ student records (entire record, not just ID) and associated test scores. - Each Student record should include Student ID, Name, GPA, Student Address, and a pointer which points to...
Python 3: Create functions to draw each of these with sides of size side:triangle, square, pentagon,...
Python 3: Create functions to draw each of these with sides of size side:triangle, square, pentagon, hexagon The function should be the shape + "2d" Use import turtle and the turtle commands: forward(), left(), right(), pendown(), penup(), done(), color() Use the goto(X,Y) function to allow the shape to be drawn at a specific location Use the x,y, and side attributes for screen position and size
A. Find the value of the mean of a sample of size 10 such that probability...
A. Find the value of the mean of a sample of size 10 such that probability of finding that value of mean or less has a probability of 0.8234, when the population mean is Mu = 604, and the population standard deviation is 146 B. Find the value of the mean of a sample of size 14 such that probability of finding that value of mean or less has a probability of 0.0468, when the population mean is Mu =...
d. How is the value of a bond determined? What is the value of a 10-year,...
d. How is the value of a bond determined? What is the value of a 10-year, $1,000 par value bond with a 10 percent annual coupon if its required rate of return is 10 percent? e. (1) What would be the value of the bond described in part d if, just after it had been issued, the expected inflation rate rose by 3 percentage points, causing investors to require a 13 percent return? Would we now have a discount or...
Python please! Create one program to include all 10 elements: Create a function that prints a...
Python please! Create one program to include all 10 elements: Create a function that prints a sentence passed to the function as parameter. On the next line, print the same sentence without the 1st and the last character, use string slicing. Use the following sentence: This is the sentence. Given a string: This string was copied in an article. Replace the relevant words to read as follows: This string was discovered in the article xyz. Given a string: This string...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT