# I can't get a floating point number to calculate in a simple progr

Page 1 of 1

## 2 Replies - 643 Views - Last Post: 22 March 2013 - 01:50 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=316356&amp;s=6c467510c07a032e4cfa14e610db7150&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 pidgeonpancakes

• New D.I.C Head

Reputation: 0
• Posts: 19
• Joined: 10-August 11

# I can't get a floating point number to calculate in a simple progr

Posted 22 March 2013 - 01:25 PM

I'm trying to learn Python on my own and I'm doing little projects to learn the nuances of the language. In the simple script below I'm trying to take a radius of a circle as input from a user and print out the circumference of the circle. It always rounds to a whole number though and I can't figure out why. Can someone give me some hints or point me in the right direction as to why? I'm not looking for full solutions here just a little direction.

```import math

print "What is the radius of your circle?(Enter as x.xx)"

radius = float(raw_input ("> "))
circumference = radius * 2.00 * math.pi

print "The circumference of your circle is: %d" % circumference
```

Is This A Good Question/Topic? 0

## Replies To: I can't get a floating point number to calculate in a simple progr

### #2 pidgeonpancakes

• New D.I.C Head

Reputation: 0
• Posts: 19
• Joined: 10-August 11

## Re: I can't get a floating point number to calculate in a simple progr

Posted 22 March 2013 - 01:31 PM

I just figured out a solution. I changed the formatting from %d to %s and that solved the problem.

### #3 sepp2k

• D.I.C Lover

Reputation: 2579
• Posts: 4,123
• Joined: 21-June 11

## Re: I can't get a floating point number to calculate in a simple progr

Posted 22 March 2013 - 01:50 PM

%f (for floating point) works too. The format specifier %d is used to print integers and, as you noticed, it will convert anything that isn't an integer to an integer before printing it.