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

C++ Assume you need to test a function named inOrder. The function inOrder receives three int...
C++ Assume you need to test a function named inOrder. The function inOrder receives three int arguments and returns true if and only if the arguments are in non-decreasing order: that is, the second argument is not less than the first and the third is not less than the second. Write the definition of driver function testInOrder whose job it is to determine whether inOrder is correct. So testInOrder returns true if inOrder is correct and returns false otherwise. ....
C++ mainDisplay.cpp Write the function displayAt that receives the two STL lists; vList and pList. The...
C++ mainDisplay.cpp Write the function displayAt that receives the two STL lists; vList and pList. The function should display the elements in vList that are in positions specified by pList. For example, if pList has the elements (2, 5, 6, 8) then the elements in positions 2, 5, 6, and 8 in vList are displayed. Use only the public STL container operations.
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.
In PYTHON: Write a function that receives an encrypted string and decrypts it as follows. The...
In PYTHON: Write a function that receives an encrypted string and decrypts it as follows. The decryption does not change the lowercase letters ‘e’, ‘w’, and ‘l’ (lowercase L). For any other character, we change it to a number using ord(). We then take the number to a power of 19, and then find the remainder after diving by 201. Finally, we take the character corresponding to the number we obtained (using chr()). For example, assume that we receive the...
1) Write a function that receives a pointer to an array along with the size of...
1) Write a function that receives a pointer to an array along with the size of the array, it returns the largest number in the array. 2) Write a function that receives a string and returns the length of it.
Python: Write a function named power() that calculates rootpow recursively. It receives two arguments root (float)...
Python: Write a function named power() that calculates rootpow recursively. It receives two arguments root (float) and pow (int) > = 1, and it returns the result root raised to power pow. The recursion of the power function is defined as: Base case: rootpow = root, if pow = 1 Recursive case: rootpow = root* rootpow-1 , otherwise. b) Develop a greatestC( ) function that determines the greatest common divisor of two integer numbers. Test greatestC() in a simple main...
"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?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT