471,347 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,347 software developers and data experts.

a few questions.

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

Oct 31 '07 #1
2 908
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
Oct 31 '07 #2
On Oct 31, 10:10 pm, Larry Bates <larry.ba...@websafe.comwrote:
for i in xrange(0,5):
hundreds, remainder=divmod(stores[i], 100)
print "Store: %i %s" % (i+1, hundreds*"*")
Yes, or since you don't need 'remainder'...

for i in range(5):
hundreds = stores[i] // 100
print "Store: %i %s" % (i + 1, '*' * hundreds)

--
Paul Hankin

Nov 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by softwareengineer2006 | last post: by
reply views Thread by connectrajesh | last post: by
8 posts views Thread by Krypto | last post: by
reply views Thread by ramu | last post: by
1 post views Thread by ramu | last post: by
reply views Thread by ramu | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.