Question

PYTHON: Write a function that takes in a number as a parameter and calculates the square of the number up to and including the value of the parameter. The function must perform the process recursively.

Answer #1

**Code:**

```
def square(n): # defining a recursive function
if n==0: # defining exit case
return 1
else:
square(n-1) # calling the function recursively
print(n*n) # printing the values
# driver code
n = int(input("Enter the number: ")) # taking input
square(n) # calling the function
```

**Output:**

Write a Python program using that takes a number as input and then
prints if the number is even or odd. The program should use a
function isEven that takes a number as a parameter and returns a
logical value true if the number is even, false otherwise.

Write a Python function that takes a filename as a parameter and
returns the string 'rows' if a file was written row by row, and
'columns' if the file was written column by column. You would call
the function with a command like filetype = myfunc(filename).

Python Jupyter Notebook
Write a python function called
profit that takes the number of meals
(n) sold by a restaurant in a month and calculates
the monthly profit given the following information: The selling
price of each meal is 12 USD (same for all meals) There is a fixed
cost of 2500 USD per month regardless of the number of meals sold.
There is a variable cost of 6 USD per each meal sold profit= total
revenue- total cost =...

Write a Python function evaluateFunction() that takes one
floating point number x as its argument and returns 3√(log|x|
)+3(x^3) The math module has a square root function and a logarithm
function

Write a function named "replacement" that takes a string as a
parameter and returns an identical string except with every
instance of the character "i" replaced with the character "n
python

Write a Python function first_chars that takes one parameter,
which is a nested list of strings. It returns a string containing
the first character of all of the non-empty strings (at whatever
depth they occur in the nested list) concatenated together. Here
are a couple of examples of how the function should behave when
you're done:
>>> first_chars(['Boo', 'is', 'happy', 'today'])
'Biht'
>>>first_chars(['boo', 'was', ['sleeping', 'deeply'],
'that', 'night', ['as', ['usual']]]) 'bwsdtnau'

Q1) Write a Python function partial_print,
which takes one parameter, a string, and prints the first, third,
fifth (and so on) characters of the strings, with each character
both preceded and followed by the ^ symbol, and
with a newline appearing after the last ^ symbol.
The function returns no value; its goal is to print its output, but
not to return it.
Q2)
Write a Python function called lines_of_code
that takes a Path object as a parameter, which is...

Write a Python function that takes two parameters: the first a
list strings and the second a single string. The function should
return True or False depending on whether the string is in the list
or not. For example, if the list contains eggs, milk, bananas, and
the second parameter is pumpkin, the function should return
False.

using Python:
Write a function named safe input(prompt,type) that works like
the Python input function, except that it only accepts the
specified type of input. The function takes two arguments:
r prompt: str
r type: int, float, str
The function will keep prompting for input until correct input of
the specified type is entered.
The function returns the input. If the input was specified to be a
number ( float or int), the value returned will be of the correct...

Write a function find square root(x) that takes as input a
number x and as output returns the square root of x. Your results
should converge to at least 6 decimal places. matlab question

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 3 minutes ago

asked 20 minutes ago

asked 25 minutes ago

asked 29 minutes ago

asked 30 minutes ago

asked 36 minutes ago

asked 40 minutes ago

asked 43 minutes ago

asked 43 minutes ago

asked 52 minutes ago

asked 1 hour ago

asked 1 hour ago