Question: Write own function series(x) which takes a single argumentxand returns the sum of the series. The calculation should be approximated to the first few terms
Write own functionseries(x)which takes a single argumentxand returns the sum of the series. The calculation should be approximated to the first few terms till the term becomes smaller thanx. Round your final answer to 4 decimal places of accuracy before returning it.
1 +1/2 +1/4 +1/8+....+1/2**n
Note:You have to be careful with the last calculated term. Depending on the formulation of your loop, you may need to add or remove it from the total sum to match your result. This will help you to understand the loop in better manner.
For example:
TestInputResultprint(series(0.5)) 1.5 print(series(0.25)) 1.75 1.75
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
