Re: a few questions.
- From: Larry Bates <larry.bates@xxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 17:10:50 -0500
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
.
- References:
- a few questions.
- From: Shawn Minisall
- a few questions.
- Prev by Date: Re: marshal vs pickle
- Next by Date: Re: A Python 3000 Question
- Previous by thread: a few questions.
- Index(es):
Relevant Pages
|