Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > beginners help

Reply
Thread Tools

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
--
 
Reply With Quote
 
 
 
 
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
 
Reply With Quote
 
 
 
 
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
certainly will get the help you want.

Diez
 
Reply With Quote
 
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
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/

 
Reply With Quote
 
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 "******"
 
Reply With Quote
 
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/
 
Reply With Quote
 
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
 
Reply With Quote
 
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



 
Reply With Quote
 
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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help ecplain Digital ISO to beginners JackVa1 Digital Photography 0 12-28-2008 03:57 PM
ASP.Net Beginners Help Rakesh ASP General 1 04-17-2007 12:56 PM
Beginners Help John Digital Photography 3 07-17-2004 12:23 AM
.NET beginners help site and code check D. Shane Fowlkes ASP General 3 11-06-2003 04:30 PM
Beginners help with password program! tjland@iserv.net Python 3 07-27-2003 03:38 PM



Advertisments