Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35866
| 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 | <msirenef@lightbird.net> |
| 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 <msirenef@lightbird.net> |
| 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 <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.1505.1357000496.29569.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
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/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2012-12-31 15:42 -0800
Re: Considering taking a hammer to the computer... Chris Angelico <rosuav@gmail.com> - 2013-01-01 11:08 +1100
Re: Considering taking a hammer to the computer... Chris Angelico <rosuav@gmail.com> - 2013-01-01 11:09 +1100
Re: Considering taking a hammer to the computer... Mitya Sirenef <msirenef@lightbird.net> - 2012-12-31 19:29 -0500
Re: Considering taking a hammer to the computer... Mitya Sirenef <msirenef@lightbird.net> - 2012-12-31 19:34 -0500
Re: Considering taking a hammer to the computer... Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-01-01 01:36 +0100
Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2012-12-31 17:30 -0800
Re: Considering taking a hammer to the computer... Mitya Sirenef <msirenef@lightbird.net> - 2012-12-31 21:00 -0500
Re: Considering taking a hammer to the computer... Tim Chase <python.list@tim.thechases.com> - 2012-12-31 22:41 -0600
Re: Considering taking a hammer to the computer... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-01 14:35 -0500
Re: Considering taking a hammer to the computer... Modulok <modulok@gmail.com> - 2012-12-31 20:59 -0700
Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2013-01-01 12:14 -0800
Re: Considering taking a hammer to the computer... Matt Jones <matt.walker.jones@gmail.com> - 2013-01-01 14:46 -0600
Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2013-01-01 13:57 -0800
Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2013-01-01 13:57 -0800
Re: Considering taking a hammer to the computer... Chris Angelico <rosuav@gmail.com> - 2013-01-02 09:01 +1100
Re: Considering taking a hammer to the computer... Dave Angel <d@davea.name> - 2013-01-01 15:28 -0500
Re: Considering taking a hammer to the computer... Dave Angel <d@davea.name> - 2013-01-01 17:34 -0500
Re: Considering taking a hammer to the computer... MRAB <python@mrabarnett.plus.com> - 2013-01-01 00:02 +0000
csiph-web