0

Python How to write a function with n as argument, If n=1 it prints f(x),If n=2 it prints f(f(x)), If n=3 it prints f(f(f(x)))?

12th Oct 2019, 5:47 AM
Susan Tandiono
Susan Tandiono - avatar
3 Réponses
+ 4
They probably want you to write two functions or have part of the code in global. One function (or the code in global) would just call the other function like this: ... for i in range(n) : x = f(x) ...
12th Oct 2019, 6:35 AM
Thoq!
Thoq! - avatar
+ 2
Do you only want to print "f(f(...f(f(f(x)))...))"? Did you mean you wanted to call these functions? For first problem I'd only use loops and string handling, but for second problem I'd use recursion: https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2465/
12th Oct 2019, 6:04 AM
Seb TheS
Seb TheS - avatar
0
They want me to write a function with f and n as arguments
14th Oct 2019, 11:34 PM
Susan Tandiono
Susan Tandiono - avatar