Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34699

Re: Hollow square program

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'python,': 0.02; 'explicitly': 0.04; 'python': 0.09; 'counting': 0.09; 'does,': 0.09; 'rows': 0.09; 'ignore': 0.13; 'do,': 0.15; 'dec': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'outputs': 0.16; 'statement.': 0.16; 'subject:program': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'variables': 0.17; 'code.': 0.20; 'otherwise,': 0.20; 'trying': 0.21; "i've": 0.23; 'header:In- Reply-To:1': 0.25; 'am,': 0.27; 'checking': 0.27; 'handling': 0.27; 'message-id:@mail.gmail.com': 0.27; 'decide': 0.28; 'post': 0.28; 'far,': 0.29; 'learn,': 0.29; 'prints': 0.29; 'spaces': 0.29; "i'm": 0.29; "we're": 0.30; 'code': 0.31; '(and': 0.32; 'you?': 0.32; 'anybody': 0.32; 'print': 0.32; 'to:addr:python- list': 0.33; 'code:': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'except': 0.36; 'but': 0.36; 'two': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'space': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'end': 0.40; 'your': 0.60; 'decision': 0.60; 'first': 0.61; 'kind': 0.61; 'time,': 0.62; 'provide': 0.62; 'between': 0.63; 'p.s.': 0.63; 'hints': 0.65; 'hey,': 0.72; 'special': 0.73; 'asterisk': 0.84; 'square,': 0.84; 'fun!': 0.95; 'taught': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=sYq50cWUvkzHIU8Zh5uXbogXAQb10Vf+4eUJCxySEL8=; b=G8587ojJM9PMzKzockpqwabZoK5oQ1UtRoExetBoV3xNkIkhvw31FtPIbVH2X3bYkT wBRraRNSNTOBtY3XusDZuirDsDnLIicyi27PUWmd44/Fv8YG9NMq1cVxr5MGfI1RbBnL 11LqtY9nuwyra97jHS+3cAUD1B+KaBDCfXObtp3m1BoFP9VOotQlx/j1ICtUKRlJ9XBE Ew4zUuiiUhDjS6Ig5l4DnEnRvxfq9NGknIPnVHbrH/3XDQvNdptuTZxE2/KXxrVPrzDD 1sl7fSyVnvgYJDShLUO1PsL4TDAOhaurZjN0AJE8JtAasa+ShzboRLWK35OsLHz2ZD7F H25g==
MIME-Version 1.0
In-Reply-To <1aa414f0-1e4c-424b-abc6-8e681631788b@googlegroups.com>
References <1aa414f0-1e4c-424b-abc6-8e681631788b@googlegroups.com>
Date Thu, 13 Dec 2012 03:59:58 +1100
Subject Re: Hollow square program
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.779.1355331602.29569.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1355331602 news.xs4all.nl 6979 [2001:888:2000:d::a6]:46448
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34699

Show key headers only | View raw


On Thu, Dec 13, 2012 at 3:48 AM,  <siimnurges@gmail.com> wrote:
> Hey, I need to write a program that prints out a square, which is empty on the inside. So far, I've made a program that outputs a square, which is full on the inside.
> P.S. Between every asterisk there needs to be a space(" ")
> Here's my code:
>
> print("Rows: ")
> rows = int(input())
> for i in range(rows):
>     for j in range(rows):
>         print("* ", end="")
>     print("")

You're going to need some kind of special handling of the beginning
and end of each row, except for the first and last rows. Since you
have i and j counting up from 0 to (rows-1), you can do this by simply
checking those two variables and then decide whether to print out a
star or a space (or, since there's spaces after the stars, whether to
print out a star and a space or two spaces).

Since you're being taught loops, I'm confident your course will have
already taught you how to make a decision in your code. It's another
Python statement.

Next time, by the way, you may want to explicitly state that this is
part of a course you're studying. Otherwise, you may come across as
sneakily trying to cheat your way through the course, which I'm sure
you would never do, would you? :) We're happy to provide hints to help
you understand Python, but not to simply give you the code (and if
anybody does, I hope you have the integrity, and desire to learn, to
ignore that post and work it out for yourself).

Have fun!

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Hollow square program siimnurges@gmail.com - 2012-12-12 08:48 -0800
  Re: Hollow square program Chris Angelico <rosuav@gmail.com> - 2012-12-13 03:59 +1100
    Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:22 -0800
      Re: Hollow square program Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-12 10:35 -0700
      Re: Hollow square program Peter Otten <__peter__@web.de> - 2012-12-12 18:44 +0100
        Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:52 -0800
          Re: Hollow square program Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-12-12 23:47 +0000
            Re: Hollow square program Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-13 00:12 +0000
        Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:52 -0800
    Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:22 -0800
  Re: Hollow square program Mitya Sirenef <msirenef@lightbird.net> - 2012-12-12 12:18 -0500
    Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:25 -0800
    Re: Hollow square program siimnurges@gmail.com - 2012-12-12 09:25 -0800

csiph-web