# Calculating volume

Page 1 of 1

## 4 Replies - 8401 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=e85d230581e5f143fad165f50ef8afbb&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.

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }