Question

In: Computer Science

Just need the desktop test for this two function a) Write a function that receives the...

Just need the desktop test for this two function
a) Write a function that receives the number of terms (n) and returns a container with the first n
TunaPoke numbers. Present a "print screen" of the results and their respective desktop test when the
function is invoked with the 16.
(b) Write a function that receives a limit number and returns a container with the first numbers
TunaPoke that do not exceed the specified limit. Present a "print screen" of the results and their respective
desktop test when function is invoked with 1000.
def tunapoke(n):
    if n==1:
        return [1]
    if n==2:
        return [1,2]
    if n==3:
        return [1,2,3]
    ls=[1,2,3]
    for i in range(3,n):
        if ls[i-1]%2==0 and ls[i-1]%3!=0:
            num=ls[i-1]+ls[i-2]
            ls.append(num)
        elif ls[i-1]%3==0 and ls[i-1]%2!=0:
            num=ls[i-1]+ls[i-2]+ls[i-3]
            ls.append(num)
        else:
            num=ls[i-1]+1
            ls.append(num)
    return ls


def tunapoke_for_nth_no(n):
    if n==1:
        return [1]
    if n==2:
        return [1,2]
    if n==3:
        return [1,2,3]
    ls=[1,2,3]
    j=0
    i=3
    while ls[i-1]<=n+1:
        if ls[i-1]%2==0 and ls[i-1]%3!=0:
            num=ls[i-1]+ls[i-2]
            ls.append(num)
        elif ls[i-1]%3==0 and ls[i-1]%2!=0:
            num=ls[i-1]+ls[i-2]+ls[i-3]
            ls.append(num)
        else:
            num=ls[i-1]+1
            ls.append(num)
        j+=1
        i+=1
    del ls[-1]
    return ls

Solutions

Expert Solution

Here are the test results:


Related Solutions

1. Write a python function that receives two positive numbers and displays the prime numbers between...
1. Write a python function that receives two positive numbers and displays the prime numbers between them.Note: A prime number (or a prime) is a natural number greater than 1 and that has no positive divisors other than 1 and itself. 2. Using either Whileor Foriteration loops, write a python code that prints the first Nnumbers in Fibonacci Sequence, where N is inputted by the user. Now, revise this code to instead print a) the Nthnumber in Fibonacci Sequence.b) the...
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following...
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following order: An array of integer values (array1). An integer representing the size of array1 (size1). An array of integer values (array2). An integer representing the size of array2 (size). The function creates a dynamic array of integers of size size1+size2 to store all the values in array1, followed by all the values in array2. The function returns the pointer used to create the dynamic...
In PYTHON: Write a function that receives a sentence and returns the last word of that...
In PYTHON: Write a function that receives a sentence and returns the last word of that sentence. You may assume that there is exactly one space between every two words, and that there are no other spaces at the sentence. To make the problem simpler, you may assume that the sentence contains no hyphens, and you may return the word together with punctuation at its end.
"sum_between" function Write a function named "sum_between" that receives 2 parameters - "start" (an int) and...
"sum_between" function Write a function named "sum_between" that receives 2 parameters - "start" (an int) and "end" (an int). It should return the sum (total) of all of the integers between (and including) "start" and "end". If "end" is less than "start", the function should return -1 instead. e.g. if you give the function a start of 10 and an end of 15, it should return 75 (i.e. 10+11+12+13+14+15)
A tree can be considered as a structured graph. Write a C++ function that receives a...
A tree can be considered as a structured graph. Write a C++ function that receives a BST object and returns its corresponding graph representation, implemented via an adjacency list. What will be the impact on the search complexity?
Write a function that receives a StaticArray with integers and returns a new StaticArray object with...
Write a function that receives a StaticArray with integers and returns a new StaticArray object with the content from the original array, modified as follows: 1) If the number in the original array is divisible by 3, the corresponding element in the new array should be a string ‘fizz’. 2) If the number in the original array is divisible by 5, the corresponding element in the new array should be a string ‘buzz’. 3) If the number in the original...
Write and test a merge function that uses a recursive algorithm to merge two sorted arrays...
Write and test a merge function that uses a recursive algorithm to merge two sorted arrays of integers. Neither list contains duplicates, and the resulting list should not contain duplicates either. Hint: You may want to call a helper function from merge. PROGRAM: C
Write a program that calls a/few function(s) to determine the smaller of two arguments. Test the...
Write a program that calls a/few function(s) to determine the smaller of two arguments. Test the program using integer, character and floating-point number arguments. Produce 3 separate programs solving the problem above. The three approaches you should be using are: a) 3 different functions (findMinimum1(), findMinimum2(), findMinimum3()), each to solve different data types parameters. b) Function overloading with only one function named findMinimum( ) c) Function template with only one function named findMinimum( )
I need to write an interpreter for arithmetic expressions in Python. This program receives an input...
I need to write an interpreter for arithmetic expressions in Python. This program receives an input string with an arithmetic expression and does: 1. prints a ">>>" as if it was a terminal 2. lets us allocate a variable to a a numeric value (as "a = 3") then it stores {'a':3} to a dictionary memory 3. whenever it receives an expression or input, transform it to postfix notation and print it (even when allocating variables) 4. it is able...
how to write a unit test for a write function in python? is there a better...
how to write a unit test for a write function in python? is there a better way than running main once and checking whether the new file path exists?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT