1. Engineering
  2. Computer Science
  3. the following are short python calculations give the answer and...

Question: the following are short python calculations give the answer and...

Question details

The following are short Python calculations. Give the answer and the Python code for each.

1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100)

2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy package to do this. Find and read the help file for the function before writing your code

3. What is the sum of the numbers from 1 to 10 (by one) multiplied by the numbers from 11 to 30 (incrementing by two) respectively? (Hint: create two arrays and use the function numpy.dot to multiply them) 4. Generate a set of 1000 normal random numbers, with mean 0 and variance

4. Calculate the mean and standard deviation of the data series.

5. Generate an array containing a set of 100 normal random numbers, with mean 0 and standard deviation 1.5 (generate the random numbers with the seed=1. Google generate random normal number with seeds). Use a for loop and the if statement to create a new array which has the same value as the original array if the elements of the original array are positive and negative of the value if the elements are negative. Calculate and compare the mean the of two arrays

6. Repeat the task in 1.5 but use matrix Boolean indexing techniques

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution