This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import doctest | |
import sys | |
import argparse | |
""" | |
---USAGE--- | |
python3 midterm-review-solution.py <name_of_function> | |
e.g python3 midterm-review-sol.py height | |
---NOTES--- | |
- if you pass all the doctests, you will get no terminal output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import doctest | |
import sys | |
import argparse | |
""" | |
---USAGE--- | |
python3 midterm-review.py <name_of_function> | |
e.g python3 midterm-review.py make_alternator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square_tree(t): | |
"""Return a tree with the square of every element in t | |
>>> numbers = tree(1, | |
... [tree(2, | |
... [tree(3), | |
... tree(4)]), | |
... tree(5, | |
... [tree(6, | |
... [tree(7)]), | |
... tree(8)])]) |