Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; '(using': 0.07; 'work!': 0.07; 'python': 0.09; '"': 0.09; 'command.': 0.09; 'loop.': 0.09; 'cc:addr:python-list': 0.10; 'skip:# 20': 0.13; '#this': 0.16; 'increment': 0.16; 'iterated': 0.16; 'processed.': 0.16; 'wrote:': 0.17; '<': 0.17; 'jan': 0.18; 'input': 0.18; 'variable': 0.20; 'cc:2**0': 0.23; 'user.': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'guess': 0.27; 'separate': 0.27; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; '\xa0we': 0.29; 'url:mailman': 0.29; 'manual': 0.29; 'skip:& 10': 0.29; 'url:python': 0.32; 'running': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'goes': 0.33; "he's": 0.33; 'skip:& 20': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'except': 0.36; 'url:org': 0.36; 'thank': 0.36; 'ok,': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'several': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'url:mail': 0.40; 'your': 0.60; "you'll": 0.62; 'different': 0.63; 'subject:...': 0.63; 'skip:n 10': 0.63; 'total': 0.65; 'equals': 0.65; 'today': 0.67; 'hotel,': 0.71; '2013': 0.84; 'calculations': 0.84; 'floors': 0.84; 'occupancy': 0.84; 'occupied': 0.84; 'rooms': 0.84; '\xa0same': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Fmq4HcJD2ipxyXWZsRvEa59RG+vAdhdI661RmTyiMSM=; b=gGp53HAi3y7SpzbkgrloiiTVS0HllWe8b/3CADKl1tSiixkOr2lj8QxU5uGx4CfAHN BFBLQ8pwn7H5zCi65nzu2aHGzOVP+kcp857ADWZuPi1IQyAgzwzh5r1ThjWW1ITeaMab BlE5coijFhkQu8xrS97u4icA84EnMLHs2F+/SI0MpdGKKS5e9u7vdxUaQHM5HthLYOfV MhPh7QIlr844XMCe1Ik+eYP42+3vgIpKjX0+6vNwQZl9y4XJSGnKrYh+xixM0j8Mwlj8 lxjJUWegMsvLQkXiI6bu53MW24IoLLAdfhej6G5xeZF0R7SSHtn/Mjki80x4HabU2YnF 07Xw== MIME-Version: 1.0 In-Reply-To: <39abb4d2-277a-4ac9-8574-0d3e3751b7ef@googlegroups.com> References: <2f5053ab-a646-49d3-a569-61468f518b9f@googlegroups.com> <39abb4d2-277a-4ac9-8574-0d3e3751b7ef@googlegroups.com> From: Matt Jones Date: Tue, 1 Jan 2013 14:46:50 -0600 Subject: Re: Considering taking a hammer to the computer... To: worldsbiggestsabresfan@gmail.com Content-Type: multipart/alternative; boundary=f46d04463180dc6ff004d2403b6e Cc: python-list@python.org 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: 182 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357073240 news.xs4all.nl 6959 [2001:888:2000:d::a6]:45706 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35916 --f46d04463180dc6ff004d2403b6e Content-Type: text/plain; charset=ISO-8859-1 rooms_on_floor is being set by the manual input for each floor iterated over in your for loop. My guess is your total_rooms value equals the rooms from the last floor you processed. Same goes for the occupied_rooms. You'll want a separate variable to increment after each occupied_rooms or rooms_on_floor is received from the user. something like...: rooms_on_floor = int(input("Enter the number of rooms on floor: ")) total_rooms += rooms_on_floor *Matt Jones* On Tue, Jan 1, 2013 at 2:14 PM, wrote: > OK, thank you all for your help yesterday! > > Here's where we are today (using python 3.3.0) > > He has everything running well except for the final calculations - he > needs to be able to total the number of rooms in the hotel, as well as the > number of occupied rooms. We have tried several different things and can't > come up with a successful command. Any help you can give will be much > appreciated!! > > Here's what he's got: > > #This program will calculate the occupancy rate of a hotel > floor_number = 0 > rooms_on_floor = 0 > occupied_rooms = 0 > total_rooms = 0 > total_occupied = 0 > > > > number_of_floors = int(input("How many floors are in the hotel?: ")) > while number_of_floors < 1: > print ("Invalid input! Number must be 1 or more") > number_of_floors = int(input("Enter the number of floors in the hotel: > ")) > > for i in range(number_of_floors): > floor_number = floor_number + 1 > print() > print ("For floor #",floor_number) > rooms_on_floor = int(input("How many rooms are on the floor ?: " )) > while rooms_on_floor < 10: > print ("Invalid input! Number must be 10 or more") > rooms_on_floor = int(input("Enter the number of rooms on floor: ")) > > occupied_rooms = int(input("How many rooms on the floor are occupied?: > ")) > > #CALCULATE OCCUPANCY RATE FOR FLOOR > occupancy_rate = occupied_rooms / rooms_on_floor > print ("The occupancy rate for this floor is ",occupancy_rate) > > #CALCULATE OCCUPANCY RATE FOR HOTEL > print() > total_rooms = sum(rooms_on_floor) #DOESN'T WORK! > total_occupied = sum(occupied_rooms) #DOESN'T WORK! > hotel_occupancy = total_occupied / total_rooms > vacant_rooms = total_rooms - total_occupied > print ("The occupancy rate for this hotel is ",hotel_occupancy) > print ("The total number of rooms at this hotel is ",total_rooms) > print ("The number of occupied rooms at this hotel is ",total_occupied) > print ("The number of vacant rooms at this hotel is ",vacant_rooms) > > -- > http://mail.python.org/mailman/listinfo/python-list > --f46d04463180dc6ff004d2403b6e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
rooms_on_floor is being set by the manual input for each floor iterated = over in your for loop. =A0My guess is your total_rooms value equals the roo= ms from the last floor you processed. =A0Same goes for the occupied_rooms. = =A0You'll want a separate variable to increment after each occupied_roo= ms or rooms_on_floor is received from the user.


rooms_on_floor =3D int(input("Enter the nu= mber of rooms on floor: "))
total_rooms +=3D rooms_on_floor

Matt Jones

On Tue, Jan 1, 2013 at 2:14 PM, <worldsbiggestsabresfan@gmail.com> wrote:
OK, thank you all for your help yesterday!

Here's where we are today (using python 3.3.0)

He has everything running well except for the final calculations - he needs= to be able to total the number of rooms in the hotel, as well as the numbe= r of occupied rooms. =A0We have tried several different things and can'= t come up with a successful command. =A0Any help you can give will be much = appreciated!!

Here's what he's got:

#This program will calculate the occupancy rate of a hotel
floor_number =3D 0
rooms_on_floor =3D 0
occupied_rooms =3D 0
total_rooms =3D 0
total_occupied =3D 0



number_of_floors =3D int(input("How many floors are in the hotel?: &qu= ot;))
while number_of_floors < 1:
=A0 =A0 print ("Invalid input! Number must be 1 or more")
=A0 =A0 number_of_floors =3D int(input("Enter the nu= mber of floors in the hotel: "))

for i in range(number_of_floors):
=A0 =A0 floor_number =3D floor_number + 1
=A0 =A0 print()
=A0 =A0 print ("For floor #",floor_number)
=A0 =A0 rooms_on_floor =3D int(input("How many rooms are on the floor = ?: " ))
=A0 =A0 while rooms_on_floor < 10:
=A0 =A0 =A0 =A0 print ("Invalid input! Number must be 10 or more= ")
=A0 =A0 =A0 =A0 rooms_on_floor =3D int(input("Enter = the number of rooms on floor: "))

=A0 =A0 occupied_rooms =3D int(input("How many rooms on the floor are = occupied?: "))

=A0 =A0 =A0 =A0 #CALCULATE OCCUPANCY RATE FOR FLOOR
=A0 =A0 occupancy_rate =3D occupied_rooms / rooms_on_floor
=A0 =A0 print ("The occupancy rate for this floor is ",occupancy_= rate)

#CALCULATE OCCUPANCY RATE FOR HOTEL
print()
total_rooms =3D sum(rooms_on_floor) #DOESN'T WORK!
total_occupied =3D sum(occupied_rooms) #DOESN'T WORK!
hotel_occupancy =3D total_occupied / total_rooms
vacant_rooms =3D total_rooms = - total_occupied
print ("The occupancy rate for this hotel is ",hotel_occupancy) print ("The total number of rooms at this hotel is ",total_rooms)=
print ("The number of occupied rooms at this hotel is ",total_occ= upied)
print ("The number of vacant rooms at this hotel is ",vacant_room= s)

--
http://mail.python.org/mailman/listinfo/python-list

--f46d04463180dc6ff004d2403b6e--