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...
Python pls create a function called search_position. This function returns a list of 2 tuples and...
Python pls create a function called search_position. This function returns a list of 2 tuples and the number should be start highest number. The first index is the number, and second are list of 2 tuples that sorted by position in alphabetical order: The first index will be position and second index will be champion's name(This also should be sorted by alphabetical order). team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2,...
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}}
Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum...
Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use at least...
Python Write function words() that takes one input argument—a file name—and returns the list of actual...
Python Write function words() that takes one input argument—a file name—and returns the list of actual words (without punctuation symbols !,.:;?) in the file. >>> words('example.txt') ['The', '3', 'lines', 'in', 'this', 'file', 'end', 'with', 'the', 'new', 'line', 'character', 'There', 'is', 'a', 'blank', 'line', 'above', 'this', 'line']
Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following:...
Create a Python main program which calls two functions enterNum and calcResult and accomplishes the following: 1. The main program calls the function enterNum 3 times. The first time enterNum is called, the main program stores the returned output in the variable xx. The second time, the returned output is stored in the variable yy and the third time in zz. 2. enterNum asks the user to enter a floating point number. This function has no input arguments and returns...
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,...
Part 3. Write a function called totalCost that takes three parameters (shipping cost, cost of one...
Part 3. Write a function called totalCost that takes three parameters (shipping cost, cost of one box, and number of boxes purchased) and returns the total cost which is computed using the following formula: shipping cost + (number of boxes purchased) * (cost of one box). Default values for the parameters are the following: shipping cost is 0, cost of one box is $4, number of boxes is 1. In the main function test your totalCost function with no arguments,...