a few questions.

S

Shawn Minisall

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
 
L

Larry Bates

Shawn said:
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
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, 100)
print "Store: %i %s" % (i+1, hundreds*"*")


-Larry
 
P

Paul Hankin

for i in xrange(0,5):
hundreds, remainder=divmod(stores, 100)
print "Store: %i %s" % (i+1, hundreds*"*")


Yes, or since you don't need 'remainder'...

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top