Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'python': 0.09; 'logic': 0.09; 'python:': 0.09; "(i'm": 0.16; 'guessing': 0.16; 'increment': 0.16; 'program?': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'task.': 0.16; 'wrote:': 0.17; 'input': 0.18; 'code.': 0.20; 'variable': 0.20; 'task': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'question': 0.27; 'forgot': 0.27; 'question:': 0.29; 'convert': 0.29; 'basic': 0.30; 'code': 0.31; '(and': 0.32; 'asking': 0.32; 'print': 0.32; 'ones,': 0.33; 'to:addr:python- list': 0.33; 'code:': 0.33; 'another': 0.33; 'clear': 0.35; 'pm,': 0.35; 'next': 0.35; 'add': 0.36; 'should': 0.36; 'does': 0.37; 'two': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'your': 0.60; 'save': 0.61; 'first': 0.61; 'different': 0.63; 'subject:...': 0.63; 'times': 0.63; 'skip:n 10': 0.63; 'more': 0.63; 'total': 0.65; 'floors': 0.84; 'occupied': 0.84; 'rooms': 0.84; '"how': 0.91 Date: Mon, 31 Dec 2012 19:34:49 -0500 From: Mitya Sirenef User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Considering taking a hammer to the computer... References: <2f5053ab-a646-49d3-a569-61468f518b9f@googlegroups.com> <50E22DEE.8050401@lightbird.net> In-Reply-To: <50E22DEE.8050401@lightbird.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357000496 news.xs4all.nl 6846 [2001:888:2000:d::a6]:48608 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35866 On 12/31/2012 07:29 PM, Mitya Sirenef wrote: > > > Hi! First I want to note that this task would be easier and better to do > with a break statement, so it's quite unfortunate that the teacher did > not cover the right tools (and very basic ones, in fact) and yet given > this task. > > Another question: are you allowed to use functions? (I'm guessing not). > > You can do this task much easier if you write it out in pseudo code > before you go to python code. For example, to convert your existing > code to pseudo code: > > * set floor_number to 0 > * get number of floors from the user > > * as long as number of floors is less than 1: > * print invalid input > * get number of floors from the user > > * as long as number of floors is more than 1: > * increment floor_number > > * get number of rooms > * as long as number of rooms is less than 10: > * get number of rooms > > * get occupied_rooms > * occupancy_rate = occupied rooms / number of rooms > > * how do we keep track of total rooms and total occupied rooms here?? > > > Does it make it easier to think about the logic of the program? > > - mitya > > I forgot to add this: question = "How many floors are in the hotel?: " number_of_floors = int(input(question)) while number_of_floors < 1: print("Invalid input!") number_of_floors = int(input(question)) It's easier to save the question in a variable and use it two times (and do the same in the next loop); it's not clear why/if the questions should be different as you're asking the user for the same thing. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/