This week we discussed recursion, which is a fascinating topic as it enables solving complex questions. Although some function can be expressed without using recursion, the form of the recursion facilitates the speed of the function. The following example can be written in both recursive and non recursive
def factorial(n): """
Recursive function computing the factorial of n
"""
return t
if n == 0: ###recursive return 1 else: return n * factorial(n - 1)
During the week's tutorial, we practiced converting filtering and list comprehension to loops. I personally find that introducing filter, zip, reduce and map will be a good topic for a lab because they highly reduce the time students take to write codes.
No comments:
Post a Comment