Question: please use python 3 for the program and please follow steps I, II, III, IV, V (1) (20 points) Consider the function F:N N given

 please use python 3 for the program and please follow steps

I, II, III, IV, V (1) (20 points) Consider the function F:N

N given by 3n+1, if n is odd, n/2, if n is

even Write Python code to accomplish the following: = (i) Write a

please use python 3 for the program

and please follow steps I, II, III, IV, V

(1) (20 points) Consider the function F:N N given by 3n+1, if n is odd, n/2, if n is even Write Python code to accomplish the following: = (i) Write a Python function named F3n1 which takes a positive integer n, and computes and returns the integer value F(n) as defined above (use the integer division operator // instead of the ordinary division operator /). For example, F3n1(10) should return 5 and F3n1(5) should return 16. (ii) Write a Python function named sequence which takes a positive integer n and returns a list containing the sequence n. F(n), F(F(n)), F(F(F(n))).... up to and including the first occurrence of a 1. For example, the command print sequence (10) should give the output [10, 5, 16, 8, 4, 2, 1] You should use the function F3n1 you wrote for Part (i). (iii) Below those two functions, insert the following code, which I will use to test your functions. N = int(input ("Enter a positive integer N:")) seq = sequence (N) print("The resulting sequence is: {0}". format (seq)) print("It has length {0}".format(len (seq))) (1) Understand the problem (20%): Read and think about the problem description, and work out an example of your own choos- ing by hand. It should be a small' enough example that working it out by hand is reasonable, yet 'large enough' to capture most things that you think might happen. Include this in com- ments at the top of your Python program file. (II) Develop an approach: (20%): Explain, in words, how to solve a general instance of the problem by hand. Include this in comments at the top of your Python program file. (III) Test your approach by hand: (20%): Take the method you just described, and apply it to a different example by hand. Verify that it works correctly. Include this in comments at the top of your Python program file. (IV) Code it: (20%): Translate your "in words" method into Python code. (V) Test and debug: (20%): Attempt to use your code on the examples you already worked out by hand, and several more. Try hard to think of examples where something could fail. If it fails on any of those, determine whether the problem comes from (III) or (IV), by adding print statements, if necessary, and working the example by hand

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!