beginners help

  • Thread starter Guido van Brakel
  • Start date
G

Guido van Brakel

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,
 
G

Guilherme Polo

2008/2/7 said:
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 ?
 
D

Diez B. Roggisch

Guido said:
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
 
S

Steve Holden

Guido said:
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
 
M

Matimus

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,

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 "******"
 
D

Dennis Lee Bieber

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
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
S

Steven D'Aprano

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,
 
T

Tim Chase

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
 
S

Steve Holden

Tim said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top