Question

Question 10 Not complete Not graded Generalize the function you wrote previously so you can pass in the name of a function as=

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE ::

def tabulate_execution(data,func_name):

eval("%s(data)"%func_name)

Explination :

Eval the method to execute the code in the String. As our function name comes as a string , So the better way is to , Make that string like a funtion call like "func_name(data)"

Now We simply Evaluate that string , Which is nothing but a Funtion call ,

"%s" will update the string with the func_name varible value with it;

"%s(data)"%"print" => "print(data)"

Execution :

def Func call(data, func name): eval (%s (data)%func name) >>> >>def AAA(S): print (S) Func_call(Hello World, AAA) Hell

>>> def Func_call(data,func_name):
... eval("%s(data)"%func_name)
...
>>> def AAA(S):
... print(S)
...
>>> Func_call("Hello World","AAA")
Hello World

On Above Example , I have Created a function AAA which prints the string given to it

Now i have called "AAA" with data "Hello World"

Func_call("Hello World","AAA")

Add a comment
Know the answer?
Add Answer to:
Question 10 Not complete Not graded Generalize the function you wrote previously so you can pass ...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am having a little trouble with my Python3 code today, I am not sure what...

    I am having a little trouble with my Python3 code today, I am not sure what I am doing wrong. Here are the instructions: and here is my code: update: I have seen I did not close x in sumFile and I am still only getting a 2/10 on the grader. any help appreciated. Lab-8 For today's lab you going to write six functions. Each function will perform reading and/or write to a file Note: In zybooks much like on...

  • Hello, can you please show me how to do this program with COMPLETE INPUT VALIDATION so...

    Hello, can you please show me how to do this program with COMPLETE INPUT VALIDATION so the computer tells the user to enter ints only if the user enters in floating point numbers or other characters? Write a method called evenNumbers that accepts a Scanner reading input from a file containing a series of integers, and report various statistics about the integers to the console. Report the total number of numbers, the sum of the numbers, the count of even...

  • Write a function decompressed(count_tuples) that takes a list of counts of '0's and '1's as defined...

    Write a function decompressed(count_tuples) that takes a list of counts of '0's and '1's as defined above and returns the expanded (un-compressed) string. You may assume that the first value of count_tuples has a count that is greater than or equal to zero and all other counts are greater than zero. Comments to show how to figure this out would be greatly appreciated A data file in which particular characters often occur multiple times in a row can be compressed...

  • This is a python matplotlib question. So it would be great if you could show me...

    This is a python matplotlib question. So it would be great if you could show me in python method. I have this loadtxt that asked to plot histogram of wind gusts(column 3) that lie in direction angle(column 2) from min angle to max angle inclusively. I don't know how to include min_angle and max_angle into my codes. Histogram of wind gust speeds As before the file akaroawindgusts.txt contains hourly maximum wind gusts speeds at the Akaroa Electronic weather station (EW)...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • I'm not getting out put what should I do I have 3 text files which is...

    I'm not getting out put what should I do I have 3 text files which is in same folder with main program. I have attached program with it too. please help me with this. ------------------------------------------------------------------------------------ This program will read a group of positive numbers from three files ( not all necessarily the same size), and then calculate the average and median values for each file. Each file should have at least 10 scores. The program will then print all the...

  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • From previous homework you are already familiar with the math function f defined on positive integers as f(x)=(3x+1)/2 if x is odd and f(x)=x/2 if x is even. Given any integer var, iteratively applying this function f allows you to produce a list of integ

    From previous homework you are already familiar with the math function f defined on positive integers as f(x)=(3x+1)/2 if x is odd and f(x)=x/2 if x is even. Given any integer var, iteratively applying this function f allows you to produce a list of integers starting from var and ending with 1. For example, when var is 6, this list of integers is 6,3,5,8,4,2,1, which has a length of 7 because this list contains 7 integers (call this list the Collatz list for 6). Write a C or C++...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT