function

Get function passed as an argument name inside another function

Get function passed as an argument name inside another function Question: I am trying to measure elapse time for different functions with simple method like this: def taketime(executable,exname=’method’): tic = time.time() exname = executable.__name__ out = executable toc = time.time() print(‘Time taken for ‘,exname,’ ‘,toc-tic,’ sec’) return out Executable is another method, can be whatever. …

Total answers: 1

Why is the first string variable from my function being printed out of line?

Why is the first string variable from my function being printed out of line? Question: I’m just a newbie in python and programming in general. And i made this simple hospital python script which prints out a specific patient’s information. The code works just fine. But for some reason the final output gives me some …

Total answers: 1

How can I sort elements of list in function?

How can I sort elements of list in function? Question: Why I got: None None def odd_even(*number): even = [] odd = [] for i in number: if i % 2 == 0: even.append(i) else: odd.append(i) print(even.sort()) print(odd.sort()) odd_even(1,5,7,8,4,3,26,59,48,7,5,45) I just tried sorting elements of list But result is None None Asked By: Necip Arda …

Total answers: 2

Need to write a function that returns all of the vowels in a word

Need to write a function that returns all of the vowels in a word Question: I am new to learning python and am struggling to create a Function to return a string only of vowels from word no matter if its a blank string, string with no vowels, or string with all vowels. This is …

Total answers: 5

Datetime / Unix Date convertor

Datetime / Unix Date convertor Question: I need an input prompt that will allow the user to enter a date at the point the function is called and then run to concert the date to Unix date for an API call later in the program. At the moment every attempt seems to hand back an …

Total answers: 1

Logic behind Recursive functions in Python

Logic behind Recursive functions in Python Question: I have the following recursive function below that returns the k to the s power of a certain integer. However I do not understand how it works. The base class is 1 when s becomes 0. How is it so that the returned value is actually k^s when …

Total answers: 1