1. Engineering
  2. Computer Science
  3. 32 create a list of integers called ilist starting with...

Question: 32 create a list of integers called ilist starting with...

Question details

3.2 Create a list of integers called ilist starting with 4, ending with 28, in steps of 6 (without manually typing the numbers, use some form of list generator). Turn that list into a numpy array with name alist and then create a new array with name slist that contains the square of values in alist. Open a file P3.2-data.txt and write a formatted columns of rows that contain pairwise the alist and slist elements. Make sure that there are exactly two spaces between the columns. Check the content of the P3.2-data.txt file and add it to the commit for this assignment. (Don't close the file yet, we will add more to it.) Write a function called fa that takes an array of numbers and a parameter q as an input and returns an array that contains the elements 𝑞log 𝑎 i +𝑞 qlog⁡ai+q where 𝑎 i ai are the elements of input array. Write the sum of the array that fa returns with alist and q=0.5 as input in a formatted output statement into the file P3.2-data.txt. The formatted statement should look exactly like this: The sum of the output array is: i.iii with 3 digits after the decimal point.

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