a few questions.
Larry Bates
larry.bates at websafe.com
Wed Oct 31 18:10:50 EDT 2007
Shawn Minisall wrote:
> 1. whats the best way to round a result to 4 decimal places?
>
> I tried round, but then read that it only works with exponents of 10.
>
> I'm trying to do it on this piece of code.
>
> time = (distance / 4900)
>
> 2. What direction would I go in if I'm getting 5 inputs from the user
> and want to make a bar table out of them where a * represents a 100 of
> the total number?
>
> For example,
>
> Store 1: * *
>
> Store 2: *
>
> Store 3: * * *
>
> ect,
>
> I already know I'm going to be expecting to use a for loop (0,4) since
> there are 5 inputs, but how to get from say, 200 to the output of * *
> I'm a little lost.
>
> thx
>
>
>
Q:1
>>> round(123.45678, 4)
123.4568
Q2:
Something like this works:
stores=[]
for i in xrange(0,5):
x=raw_input("input number for store=%i ?" % i)
stores.append(int(x))
for i in xrange(0,5):
hundreds, remainder=divmod(stores[i], 100)
print "Store: %i %s" % (i+1, hundreds*"*")
-Larry
More information about the Python-list
mailing list