Question: Python3 help please :) Please try and comment so I can follow the logic of what you are doing. It would be much appreciated. no

Python3 help please :)

Please try and comment so I can follow the logic of what you are doing. It would be much appreciated.

no usage imports, sets, dictionaries, file I/O, or self-made classes. Just focus on lists and loops. no zip() function, and no list

Python3 help please :) Please try and comment so I can follow

Functions def sum_divisors(n): Given a positive integer n, calculate and return the total of all of its positive divisors. Note: n is also a divisor of itself Assume: n is a positive integer Restrictions: remember, you may not call sum() sum-divisors (6) sum-divisors(1) sum-divisors(7) o o 12 1 8 # divisors : 1,2,3,6 # only divisor: 1 # divisors: 1,7 def pi(precision): One can approximate the value of pi by using the Leibniz formula (given below) that calculates a theoretically infinite sum. In practice, though, we run a finite summation where the larger the number of terms the better the approximation of pi. Given precision as a float, this function approximates the value of pi using the Leibniz formula. The function should stop the infinite summation when the improvement of the approximation becomes smaller than the provided precision (-1) 4 4 4 4 4 4 2k+1 13 5 7 9 11 Assume: precision is a positive float value. Restrictions: you must use a loop in your implementation to receive credit. pi(1.0) pi(0.5) pi(0.1) o o 3.466666666666667 # total of the first three terms since 4/5c1.0 3.3396825396825403# total of the first five terms since 4/3c0.5 3.189184782277 596 # total of the terms up to and including 4/41 def span (nums): Given a list of numbers, return the difference between the largest and smallest number If the list is empty, return zero. o Assume: nums is a list of any length, and all values are numbers. o Restrictions: remember, you may not call min(),max) or other related built-in functions. span([1,0,-10,8.51) span ([3,3,3] span (]) 18.5 # largest is 8.5; smallest is -10 # 3 is the only value # no value at all. . def single_steps (nums): Given a list of numbers, count and return how many neighboring values in the list differ by one Assume: nums is a list of any length, and all values are integers. Restrictions: no extra restrictions. single steps ([,1,8,7,6])-3three pairs differ by 1: (,1), (8,7), (7,6) single_steps ([,-3,8,6]) single_steps ([]) o o # no neighboring values differ by 1 # empty list def remove_echo(xs): An echo is a contiguous sequence of identical values. Given xs as a list of values, this function returns a copy of xs with all but one value for each echo removed. Assume: xs is a sequence of any length. Restrictions: remember, you may not call.index(); do not modify xs. remove echo([1,1,3,3,3,2,1,2,2]) remove echo ([1,3,2,1,2]) remove-echo([ "B", "a","1","1","o", "o", "n")) remove_echo(]) o o # no echo [ "B", "a","1","o", "n"] # a list of strings

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!