Velocity Reviews > beginners help

# beginners help

Guido van Brakel
Guest
Posts: n/a

 02-07-2008
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
--

Guilherme Polo
Guest
Posts: n/a

 02-07-2008
2008/2/7, Guido van Brakel <(E-Mail Removed)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

Diez B. Roggisch
Guest
Posts: n/a

 02-07-2008
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

Steve Holden
Guest
Posts: n/a

 02-07-2008
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/

Matimus
Guest
Posts: n/a

 02-07-2008
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 "******"```

Dennis Lee Bieber
Guest
Posts: n/a

 02-07-2008
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://www.velocityreviews.com/forums/(E-Mail Removed) (E-Mail Removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (E-Mail Removed))
HTTP://www.bestiaria.com/

Steven D'Aprano
Guest
Posts: n/a

 02-07-2008
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

Tim Chase
Guest
Posts: n/a

 02-07-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

Steve Holden
Guest
Posts: n/a

 02-07-2008
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/