Create Test Cases! Try and do things that might break your code. Be fearless. But be fair; do not violate the given preconditions.
Import the run_tests
file to do this.
#################################################
# Author:
# Date:
# harder_functions.py
#
# Make these happen using RECURSION!
from rt import close_enough, run_test, run_test_float
###################Problem 1################
def rectangle(m, n):
"""Precondition: m and n are nonnegative integers.
Postcondition: returns a string containing
a rectangle of *s to the screen that
has m rows and n columns"""
pass
###################Problem 2################
def power(base, exp):
"""prec: base is a number, exp is an integer`
postc: computes base**exp from scratch (no using libraries
or built-in functions). Pay attention to the case where exp < 0!"""
return 1
###################Problem 3################
def convert_to_binary(n):
"""prec: n is an integer
postc: retrns a string containing a binary representation of n.
return """
###################Problem 4################
def sum_of_digits(n):
"""precondition: n is an integer
postcondition: returns the sum of the digits of n. You should
be able to take negative input; in such cases disregard the - sign. """
return 0
###################Problem 5################
def super_summer(f, n):
"""precondition: f is a function that is defined for all nonnegative
integers.
postcondition: returns sum(f(k), k = 1..n) """
return 0
###################Problem 6################
def reverse_string(x):
"""prec: x is a string
postc: return a string containing x is reverse."""
return ""
###################Problem 7################
def sum_from(n, x):
"""prec: n is an integer, x is a list of integers.
postc: returns a sublist of x whose sum is n if it exists
and the graveyard object None otherwise. """
return None
def main():
# run your tests in this main function
print("###################Problem 1################")
print("###################Problem 2################")
print("###################Problem 3################")
print("###################Problem 4################")
print("###################Problem 5################")
print("###################Problem 6################")
print("###################Problem 7################")
main()