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).
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+)...
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%....
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...
In Python syntax, create a list of 10 numbers (any numbers). Create your list 3 times,...
In Python syntax, create a list of 10 numbers (any numbers). Create your list 3 times, each time using a different syntax to define the list. Write a while loop that prints the numbers from 1 to 10. Convert your previous loop into a for loop. Rewrite your for loop to only have one number in the range. Write a for loop to print out each item of your list of 10 numbers, all on the same line, separated by...
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...
Directions of assignment: - Create an array of words of size 10. - Prompt the User...
Directions of assignment: - Create an array of words of size 10. - Prompt the User to enter the 10 integers. Populate the array with the integers as they are entered. - You MUST use indexed addressing to traverse through the array. - Determine the maximum and the minimum values contained within the array and print them out. Can you see what I am doing wrong here, the last part (to find the min and max) I can't seem to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT