1.The standard Python function sum takes a list as argument and computes the sum of the elements in the list. Write your own version 'mysum()' which · accepts a container as a single argument (list,...

1 answer below »
python 3 codes are required


1.The standard Python function sum takes a list as argument and computes the sum of the elements in the list. Write your own version 'mysum()' which · accepts a container as a single argument (list, dictionary, tuple, set) and · returns the sum of the elements as a single number. · No testing for non-numeric data is required. You might need to treat different types of containers differently. 2. The mathematician Ramanujan found an infinite series that can be used to generate a numerical approximation of ππ: 1/π=(2sqrt(2)/9801)*∑00k=0 ((4k)!(1103+26390k))/((k!)4 *3964k ) . Write a function called 'estimate_pi()' that · takes no input argument · uses the formula above to compute an estimate of ππ. · Return your result, noting that a manual return value of ππ (math.pi or 3.1415...) will be moderated to zero marks. · Use a 'while' loop to compute terms of the summation until the last term is smaller than 1.0e-15 (i.e. 10-15). · Note that you'll either have to use a built-in factorial function or use your own from earlier exercises in the script. 3. Write a function 'mean_rms_file()' which · receives as single input argument a file name as a string. · The function shall open the file and · read the single-column data and · calculate the mean value of the numbers in the file as well as the RMS (root mean square) value, see below. · You can test your function with Spyder using the supplied 'data1.txt' file (Result: mean =20.95=20.95, RMS =21.1569=21.1569...). · Return the mean value and the RMS value as a tuple in that order. Note that the RMS value is defined as XRMS=sqrt(σ2+xmean) where σ2 is the variance of the data, xmean the mean value. 4. A ball thrown at an angle θθ with initial speed v0v0 on Earth follows a trajectory f(x)=xtanθ−1/(2*v02 )*g*x2 /(cos2(x))+y0 where g=9.81 ms-2, speed in units of ms-1 and an initial height y0y0 in metres. Set y0=0  and write a function 'trajectory()' that · has three input variables: xdata (a list), speed and angle (constant numbers each, angle in degrees) in that order. · Return the calculated list of height values, f(x), containing only positive or zero values for the ball height, i.e. remove all negative values before returning the resulting list. · The moodleX test code will take the returned list and test maximum height at given speed and angle. You can test your function with Spyder by writing a test function, calling your trajectory function with a speed of 20 ms-1−1, an angle of 45 degrees and a list made from the python function 'range(100)'. Printing the maximum of the list with 'max(result)' where result is the output of the trajectory function should yield 10.19 in this example.
Answered Same DayFeb 01, 2022

Answer To: 1.The standard Python function sum takes a list as argument and computes the sum of the elements in...

Sathishkumar answered on Feb 01 2022
110 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here