beginners help

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

1. Guido van BrakelGuest

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

2. Guilherme PoloGuest

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

3. Diez B. RoggischGuest

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

Diez

Diez B. Roggisch, Feb 7, 2008
4. Steve HoldenGuest

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

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

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 (Text):

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
6. Dennis Lee BieberGuest

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
7. Steven D'ApranoGuest

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
8. Tim ChaseGuest

> 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
9. Steve HoldenGuest

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