Python · lambda, Recursion & Built-in Functions

What does this print? ``` def fac(n): if n > 1: return fac(n-1) * n return 1 print(fac(0)) ```

Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.

Get it on App StoreGet it on Google Play

This is one card from the KnowCard library — thousands more across SAP, Linux, Python and more. In the app you get the answer, AI explanations, and cards that come back right before you would forget them. Free to start on iOS, Android or the web.

More in lambda, Recursion & Built-in Functions

A teammate wants a lambda that prints a value and returns it: lambda x: print(x); return x. Why won't this work?
You need to sort people by their age attribute. A colleague writes people.sort(lambda p: p.age). What's wrong?
What does this print? ``` funcs = [lambda: i for i in range(3)] print([f() for f in funcs]) ```
In a loop you build callbacks with lambda: x and they all end up using the last value of x. What's the standard fix?
A deep recursive function on a big input dies with RecursionError: maximum recursion depth exceeded. Why, and what's the usual fix?
What does this print? ``` r = map(lambda x: x*2, [1, 2, 3]) print(len(r)) ```

Start learning today

Free to start — download the app or use it in your browser.

Get it on App StoreGet it on Google Play