beginners help

Tim Chase python.list at tim.thechases.com
Thu Feb 7 16:57:17 EST 2008


> If i enter a center digit like 5 for example i need to create two
> vertical and horzitonal rows that looks like this. If i enter 6 it shows
> 6 six starts. How can i do this, because i don't have any clue.
>
> *****
> *   *
> *   *
> *   *
> *****

Well we start by introducing the neophite programmer to unit-testing:

   import unittest

   class Tester(unittest.TestCase):
     def testFive(self):
       """ digit like 5 for example i need to
           create two vertical and horzitonal
           rows that looks like this
           *****
           *   *
           *   *
           *   *
           *****
       """
       assert five() == "*****\n*   *\n*   *\n*   *\n*****"

     def testSix(self):
       """If i enter 6 it shows 6 six starts"""
       assert six() == "start" * 6

   def five():
     return "*****\n*   *\n*   *\n*   *\n*****"

   def six():
     return "start" * 6

   if __name__ == "__main__":
     unittest.main()


works for me... ;)

-tkc






More information about the Python-list mailing list