# Calculating volume

Page 1 of 1

## 4 Replies - 4759 Views - Last Post: 08 July 2013 - 08:42 AMRate 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=324451&amp;s=4b271a70e2b2ab471cd37a74eff6a1d4&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 laffy

Reputation: 0
• Posts: 5
• Joined: 08-July 13

# Calculating volume

Posted 08 July 2013 - 06:39 AM

Working on code to get volume of cubes...

How do I get user input?

```def BV (length=1, height = 1, width = 1):
"""calc box volume"""
volume = length * height * width  # volume is a local variable
return volume
```

Thanks
Is This A Good Question/Topic? 0

## Replies To: Calculating volume

### #2 ConciselyVerbose

• D.I.C Regular

Reputation: 91
• Posts: 315
• Joined: 05-July 13

## Re: Calculating volume

Posted 08 July 2013 - 08:00 AM

What python are you using? For 2.7 and lower, use raw_input(). For 3 and up, input replaces raw_input

### #3 laffy

Reputation: 0
• Posts: 5
• Joined: 08-July 13

## Re: Calculating volume

Posted 08 July 2013 - 08:23 AM

I'm using 2.7

### #4 laffy

Reputation: 0
• Posts: 5
• Joined: 08-July 13

## Re: Calculating volume

Posted 08 July 2013 - 08:34 AM

```def BV (length=1, height = 1, width = 1):
"""calc box volume"""
volume = length * height * width  # volume is a local variable
return volume

length = int(raw_input("Enter box length: "))
height = int(raw_input("Enter box height: "))
width = int(raw_input("Enter box width: "))
```

### #5 ConciselyVerbose

• D.I.C Regular

Reputation: 91
• Posts: 315
• Joined: 05-July 13

## Re: Calculating volume

Posted 08 July 2013 - 08:42 AM

Yep. You may want to handle bad input, and you need to call the function, but I just tested that (on an ipad with 2.4 or so) and it appears to work as intended.