Question

python pls Create function math_life() this function takes one or more argument. If this function called...

python pls

Create function math_life()

this function takes one or more argument.

If this function called with no argument, raise typeError. The math_life() function returns to a function defined inside. this will take a one argument. For the second argument, it will calculate second function passed to math_life(). You should assume that the math_life() passed x functions, when it called the x times it will calculate the xth function passed to math_life() arguments when it called x+1 time it again calculate the 1st function passed to math_life() on it argument. it keeps cycling through x function passed as arguments to the math.life().

For example

hello = math_life((lambda x: x+2),(lambda x: x*3), lambda(x: x**3))

this will be execute hello(1) returns 3 then execute hello(3) returns 9 and then execute 9 will return 81.

For additional, determine how many times math_life() called and stores the number and output them.

Homework Answers

Answer #1

A function that takes 2 arguments: a string, strText and a number, int number that prints strText intNumber times.

def print_string(strText,intNumber):

print "\n",strText * intNumber

def print_string(strText,intNumber):

print "\n",strText * intNumber

string = raw_input("Enter a string: ")

num = int(input("\nEnter a number: "))

print_string(string,num)


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
8) Write Python code for a function called occurances that takes two arguments str1 and str2,...
8) Write Python code for a function called occurances that takes two arguments str1 and str2, assumed to be strings, and returns a dictionary where the keys are the characters in str2. For each character key, the value associated with that key must be either the string ‘‘none’’, ‘‘once’’, or ‘‘more than once’’, depending on how many times that character occurs in str1. In other words, the function roughly keeps track of how many times each character in str1 occurs...
In lambda calculus, a function denoted by λ takes exactly one argument and returns exactly one...
In lambda calculus, a function denoted by λ takes exactly one argument and returns exactly one output. With this in mind, write the λ-calculus expression of a function that takes two arguments and returns the second. Explain briefly (no more than 3-4 sentences) how your expression is doing what is being asked to do. [Hint: think about this function in terms of Currying.]
Write a Python function evaluateFunction() that takes one floating point number x as its argument and...
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
Python pls create a function called search_position. This function returns a dictionary. team1 = {'Fiora': {'Top':...
Python pls create a function called search_position. This function returns a dictionary. team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2, 'Top': 5},'Shaco': {'Jungle': 4, 'Top': 2, 'Mid': 1}} def search_position(team1): should return {'Top': {'Fiora': 1, 'Yasuo':5,'Olaf':3,'Shaco':}, 'Jungle': {'Shaco': 4}, 'Mid': {'Yasuo', 2, 'Fiora': 4,'Olaf':2}, 'Bottom': {'Fiora': 3}, 'Support': {'Olaf': 4}}
Create a function called, convert. This function receives a string parameter called word which only contains...
Create a function called, convert. This function receives a string parameter called word which only contains digits (the string represents a positive number) and returns a list of numbers. This is how the function works: - This function calculates the number of times each digit has repeated in the input string and then generates a number based on that using the following formula and adds it to a list. For instance, if the digit x has been repeated n times,...
Problem 2: Python 3 Implement a function called gee_whiz that does the following: given argument n,...
Problem 2: Python 3 Implement a function called gee_whiz that does the following: given argument n, a positive integer, it returns a list of n tuples corresponding to the numbers 1 through n (both inclusive): the tuple for the number k consists of k as the first component, and exactly one of the following strings as the second: • the string 'two!' if k is divisible by 2 • the string 'three!' if k is divisible by 3 • the...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
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...
C++ only: Please implement a function that accepts a string parameter as well as two character...
C++ only: Please implement a function that accepts a string parameter as well as two character arguments and a boolean parameter. Your function should return the number of times it finds the character arguments inside the string parameter. When both of the passed character arguments are found in the string parameter, set the boolean argument to true. Otherwise, set that boolean argument to false. Return -1 if the string argument is the empty string. The declaration for this function will...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...