PYTHON
The first function you will write should be called ‘countDown’. Your function should take zero (0) arguments. The function should return one (1) list containing integers from 10 to 1 and finally, the string “Liftoff!”. (i.e., [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, ‘Liftoff!’]). You function must be recursive (i.e., it should contain a call to itself within the function body). You will get NO credit if you use any loops (for, while, etc).

For a recursive function to be executed properly, there should be one criteria to stop the recursion called base case. If base case is not presion, recursion will go on infinitely
There are two ways to hold the base case without passing it into parameter.
1) passing optional parameter. : - Here parameter is passed but is optional. i.e. while calling method, we dont need to specify is
the code is as below: -
def countDown(n=10):
if n == 0:
return ['Liftoff!']
else:
return [n] + countDown(n-1)
print(countDown())
2. By accessing some global variable
Here we use some declared global variable to create a base case. The code is as below
n = 11
def countDown():
global n
n = n - 1
if n == 0:
return ['Liftoff!']
else:
return [n] + countDown()
print(countDown())
3. Using method variables
def countDown():
countDown.counter = countDown.counter - 1
if countDown.counter == 0:
return ['Liftoff!']
else:
return [countDown.counter] + countDown()
countDown.counter = 11
print(countDown())
![main.py def countDown (): [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, Liftoff!] countDown . counter countDown counter - 1 if countDown.](http://img.homeworklib.com/questions/3e20eb70-052b-11ec-9c89-a1e8371237e4.png?x-oss-process=image/resize,w_560)
4. Using helper function
def countDown():
return countDownHelper(10)
def countDownHelper(num):
if num == 0:
return ['Liftoff!']
else:
return [num] + countDownHelper(num-1)
print(countDown())
![main.py - def countDown (): [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, Liftoff!] return countDownHelper (10) def countDownHelper(num):](http://img.homeworklib.com/questions/3ea6a3c0-052b-11ec-90de-8fee0624de8a.png?x-oss-process=image/resize,w_560)
Note:- Without base case we cannot define any recursion. Please comment if you have any query on this.
PYTHON The first function you will write should be called ‘countDown’. Your function should take zero...
USING PYTHON! The second function you will write should be called ‘varOrd’. Your function should take two (2) arguments, an integer and a string. The function should return one (1) integer calculated as follows. If the input integer is 1, the function should return the sum of the return value of the ord() function on each character of the string (e.g., varOrd(1, ‘cat’) should return the result of ord(‘c’) + ord(‘a’) + ord(‘t’)). If the input integer is 2, the...
Please solve the program in C++(Recursive) Write a function called factorialIterative(). This function should take a single BIG integer (bigint) as its parameter n, and it will compute the factorial n! of the value and return it as its result (as a bigint). Write this functions using a loop (do not use recursion). 2. Write the factorial function again, but using recursion. Call this function factorialRecursive(). The function takes the same parameters and returns the same result as described in...
Task 5
Write a function called “earring_iter” that takes two integer
arguments, size and count. This function should use a (for or
while) loop to draw a Hawaiian earring
containingcount-manycircles,wherethefirstcircledrawnhassizesize,andeachsubsequent
circle has size earring_ratio times the size of the previous
circle.
Here is a recursive specification for drawing a Hawaiian earring
of a given size:
• To draw a Hawaiian earring of a given size with zero hoops, do
nothing.
• To draw a Hawaiian earring of a given size...
write a function named count_to_n . This function should take one argument (you can safely assume that all arguments will always be positive integers), and it should print all integer values from 1 to the argument value - one number on each line. This function must use a while loop to count from 1 to the value of the argument. Here are a couple of example calls to the count_to_n function along with the expected print output for that call....
Python For this one use the random library. First, create a function called getRands that will have a parameter called ceiling. Within that function, create a loop that will loop the 10 times and in each loop, it creates a variable that is an integer between 1 and the number in the variable ceiling. Then test if that integers is less than 3. If it is, print that number. Now call getRands and pass in the argument: 10. You must...
PLEASE USE WHILE LOOP (NOT FOR LOOPS). Python programming. In this problem, you should write one function named multiply. This function should accept one parameter, which you can assume will be a list with one or more integers in it. (If you don’t know what I mean when I say “list of integers”, go do the reading!) The function should loop through all of the numbers in the list, and multiply all of the numbers together. It should return the...
Problem 1. Write a Python function times_i_at_odd(L) that takes as arguments a list L and returns a list consisting of the elements of L multiplied by the index number of the element at odd positions. (Use list comprehensions) >>> times_i_at_odd([1,2,3,4,5,6,7,8,9,10]) [2, 12, 30, 56, 90] Problem 2. Write a recursive function sum_cols(grid, n) that takes a list of lists of integers grid and integer n and returns the sum of column n in grid. For example, the call sum_cols([[1,2,3,4], [10,20,30,40],...
USING MATLAB...Write a function that creates a structure variable called createSpacecraft. The function should take four inputs, a number called mass (in kg), a number called fuel (in joules of energy), a number called orbit (in meters), and a number called engine (in newtons). It should return an output structure called spacecraft containing each of those values. Please ensure that both the function name, AND the names of variables within the spacecraft structure are exactly as instructed
Create a file called Sort.py (note the capitalization). Within that file, write two different Python functions. Each function will take an array of integers as a parameter and sort those integers in increasing order. One will use insertion sort, and the other will use selection sort (described below). Simple functions will suffice here; do not create any classes. Your insertion sort function should be called insertion_sort(arr). Your selection sort function should be called selection_sort(arr). Selection sort must use a while...
Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...