@extends('template')
@section('title')
Lab 12: Fruitful recursion
@stop
@section('content')
# Lab 12, Extra fruitful recursion practice
If you've finished the previous parts of the lab, here are some extra
functions to work on to practice fruitful recursion. __Create a new file
in your `lab12` folder called `extra.py`__ to define these functions. You
can use the provided `test_extra.py` file to check your results for each
function as you work.
## `sumEvens`
Partner A
Write a **fruitful recursive** function called `sumEvens` that will take
a list of integers and **return** the sum of all of the even numbers in
the list (the numbers which are even, not the even-index values).
For example:
```py
sumEvens([1, 2, 3, 4]) # returns 6
sumEvens([2, 4, 1, 3]) # returns 6
sumEvens([]) # returns 0
sumEvens([1, 3, 5]) # returns 0
sumEvens([4, 6, 8, 9]) # returns 18
```
## `evenOddSums`
Partner B
Write a **fruitful recursive** function called `evenOddSums` that takes a
list of numbers and returns a tuple containing two numbers: first the sum
of all of the odd numbers in the list, and second, the sum of all of the
even numbers. For example:
```py
evenOddSums([1, 2, 3]) # returns (4, 2)
evenOddSums([]) # returns (0, 0)
evenOddSums([2, 4, 6]) # returns (0, 12)
evenOddSums([11, 12, 15, 4, 3]) # returns (29, 16)
```
## `countPythonFiles`
Partner A
Write a **fruitful recursive** function called `countPythonFiles` that
takes a directory path and returns the number of files in that directory
or sub-directories whose filenames end in '.py'. Note that for this
function you'll want to add `import os` to your file. Examples:
```py
countPythonFiles('testdir') # returns 5
countPythonFiles(os.path.join('testdir', 'remember')) # returns 2
countPythonFiles(os.path.join('testdir', 'pset')) # returns 2
countPythonFiles(os.path.join('testdir', 'pset', 'shrub', 'images')) # returns 0
```
@include('/labs/lab12/_toc')
@stop