beginners help

Discussion in 'Python' started by Guido van Brakel, Feb 7, 2008.

  1. Hello

    I totally new to python and i'm doing a python course now. Maybe someone
    could help me a little bit here:

    I need to create this script.

    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.

    *****
    * *
    * *
    * *
    *****

    Kind Regards,

    --
    Guido van Brakel
    --
     
    Guido van Brakel, Feb 7, 2008
    #1
    1. Advertising

  2. 2008/2/7, Guido van Brakel <4all.nl>:
    > Hello
    >
    > I totally new to python and i'm doing a python course now. Maybe someone
    > could help me a little bit here:
    >
    > I need to create this script.
    >
    > 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.
    >
    > *****
    > * *
    > * *
    > * *
    > *****
    >


    This would totally ruin the purpose of your course. Did you try
    anything at all ?

    > Kind Regards,
    >
    > --
    > Guido van Brakel
    > --
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >



    --
    -- Guilherme H. Polo Goncalves
     
    Guilherme Polo, Feb 7, 2008
    #2
    1. Advertising

  3. Guido van Brakel wrote:

    > Hello
    >
    > I totally new to python and i'm doing a python course now. Maybe someone
    > could help me a little bit here:
    >
    > I need to create this script.
    >
    > 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.
    >
    > *****
    > * *
    > * *
    > * *
    > *****


    This list is not there to provide you with solutions to your homework. If
    you try and show us your efforts, or have otherwise concrete questions you
    certainly will get the help you want.

    Diez
     
    Diez B. Roggisch, Feb 7, 2008
    #3
  4. Guido van Brakel

    Steve Holden Guest

    Guido van Brakel wrote:
    > Hello
    >
    > I totally new to python and i'm doing a python course now. Maybe someone
    > could help me a little bit here:
    >
    > I need to create this script.
    >
    > 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.
    >
    > *****
    > * *
    > * *
    > * *
    > *****
    >

    Welcome to c.l.py.

    We have a tradition here of helping people with classwork by asking them
    to make an attempt to solve their problem. Then we will point out what
    is wrong with your effort and try and help you to improve it by
    improving your understanding of Python.

    We wouldn't be helping you very much if we just gave you an answer that
    you had no understanding of, and it would be embarrassing if your
    teacher asked you to explain it.

    It doesn't matter how awful your code is, people here are generally kind
    to those making an honest first attempt.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
     
    Steve Holden, Feb 7, 2008
    #4
  5. Guido van Brakel

    Matimus Guest

    On Feb 7, 7:53 am, Guido van Brakel <guidovb1@invalid> wrote:
    > Hello
    >
    > I totally new to python and i'm doing a python course now. Maybe someone
    > could help me a little bit here:
    >
    > I need to create this script.
    >
    > 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.
    >
    > *****
    > * *
    > * *
    > * *
    > *****
    >
    > Kind Regards,
    >
    > --
    > Guido van Brakel
    > --


    If you turn this in you will be rewarded for your effort :)
    Code:
    side = input("How many stars on a side?:")
    if side == 5:
        print "*****"
        print "*   *"
        print "*   *"
        print "*   *"
        print "*****"
    elif side == 6:
        print "******"
        print "*    *"
        print "*    *"
        print "*    *"
        print "*    *"
        print "******"
    
     
    Matimus, Feb 7, 2008
    #5
  6. On Thu, 07 Feb 2008 13:53:48 +0100, Guido van Brakel <guidovb1@invalid>
    declaimed the following in comp.lang.python:


    >
    > If i enter a center digit like 5 for example i need to create two


    No idea of what "center digit" means (to me it implies a digit in
    the middle of a multi-digit number: 123, 73837, 04377 [2, 8, 3,
    respectively]).

    > 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.
    >

    Attempting to paraphrase, you are supposed to produce an ASCII art
    (okay, maybe ISO-Latin-1, or some other set -- but * is pretty common in
    all) box whose sides are the length (call it "n") entered.

    You need only a few things...

    Line 1 is "n" copies of *
    Lines 2..n-1 are *, 2..n-1 copies of space, *
    Line n is "n" copies of *

    Brute force mode (not optimized) would be a loop for line 1; a loop
    for lines 2..n-1 that contains a loop for spacing the *, and a final
    loop for line n.

    Python is high-level enough that it can be done with one loop
    containing an if/else block.
    --
    Wulfraed Dennis Lee Bieber KD6MOG

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, Feb 7, 2008
    #6
  7. On Thu, 07 Feb 2008 13:53:48 +0100, Guido van Brakel wrote:

    > Hello
    >
    > I totally new to python and i'm doing a python course now. Maybe someone
    > could help me a little bit here:
    >
    > I need to create this script.
    >
    > 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.
    >
    > *****
    > * *
    > * *
    > * *
    > *****



    Start by writing some Python code that draws a horizontal line of stars.
    (Hint: "print '*' draws one star.)

    Now write some code that draws a column of stars.

    Now combine them to draw a square.

    Come back when you have some more specific questions.


    Regards,



    --
    Steven
     
    Steven D'Aprano, Feb 7, 2008
    #7
  8. Guido van Brakel

    Tim Chase Guest

    > 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
     
    Tim Chase, Feb 7, 2008
    #8
  9. Guido van Brakel

    Steve Holden Guest

    Tim Chase wrote:
    >> 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... ;)


    I think you've scared him away, Tim!

    regards
    Steve

    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
     
    Steve Holden, Feb 7, 2008
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Clemens Bosch

    Beginners questions for addition

    Clemens Bosch, Dec 2, 2004, in forum: VHDL
    Replies:
    0
    Views:
    571
    Clemens Bosch
    Dec 2, 2004
  2. dwerdna

    Dual port Ram - for beginners

    dwerdna, Apr 3, 2005, in forum: VHDL
    Replies:
    7
    Views:
    23,546
    dwerdna
    Apr 8, 2005
  3. Replies:
    3
    Views:
    409
  4. D. Shane Fowlkes

    .NET beginners help site and code check

    D. Shane Fowlkes, Nov 6, 2003, in forum: ASP General
    Replies:
    3
    Views:
    102
  5. Rakesh

    ASP.Net Beginners Help

    Rakesh, Apr 17, 2007, in forum: ASP General
    Replies:
    1
    Views:
    125
    Bob Barrows [MVP]
    Apr 17, 2007
Loading...

Share This Page