# Converstion Program Equation Help

Page 1 of 1

## 11 Replies - 1440 Views - Last Post: 30 May 2008 - 09:24 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=53290&amp;s=75594805631f6b4d04212db11b50b518&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 zartek

Reputation: 0
• Posts: 19
• Joined: 29-May 08

# Converstion Program Equation Help

Posted 29 May 2008 - 03:39 AM

This is the first program i have ever written and im having problems with the conversion equation for Ounces to Pounds
here is my code plz help

```def Greydon():
Ounce	   = input ('Weight in Ounces:');
Pound	   = (1/16);
print Ounce, 'Ounce =', Pound, 'Pound';

```

what am i doing wrong
Is This A Good Question/Topic? 0

## Replies To: Converstion Program Equation Help

### #2 .Maleficus.

Reputation: 2
• Posts: 129
• Joined: 07-March 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 03:55 AM

Are you trying to do the actual math and convert ounces to pounds or just print "Ounces = (1/16) Pound"?

Also, what errors are you getting?

### #3 zartek

Reputation: 0
• Posts: 19
• Joined: 29-May 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 04:03 AM

.Maleficus., on 29 May, 2008 - 03:55 AM, said:

Are you trying to do the actual math and convert ounces to pounds or just print "Ounces = (1/16) Pound"?

Also, what errors are you getting?

Well im trying to get the actual conversion equation to be right
oh and no errors just wrong answers
Thanks man for all your help, so hard getting help on forums these days...

Z

### #4 baavgai

• Dreaming Coder

Reputation: 4888
• Posts: 11,284
• Joined: 16-October 07

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 04:54 AM

You forgot to apply your conversion to your value. Also, python hates semicolons.

This:
```Pound = (1/16);
```

should probably be this:
```Pound = Ounce/16
```

### #5 .Maleficus.

Reputation: 2
• Posts: 129
• Joined: 07-March 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 08:37 AM

```def greydon():
ounces = input('Weight in Ounces: ')
pound = str(ounces/16)
print 'Weight is %s lbs' % pound
```

IIRC Python convention is mostly lowercase with underscores.

This post has been edited by .Maleficus.: 29 May 2008 - 08:38 AM

### #6 zartek

Reputation: 0
• Posts: 19
• Joined: 29-May 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 12:40 PM

.Maleficus., on 29 May, 2008 - 08:37 AM, said:

```def greydon():
ounces = input('Weight in Ounces: ')
pound = str(ounces/16)
print 'Weight is %s lbs' % pound
```

IIRC Python convention is mostly lowercase with underscores.

the last line of code 'print...'
did not work, though the other conversion equation ounce/16 works just find, can you explain the last line of code to me?

Thanks again

Z

### #7 .Maleficus.

Reputation: 2
• Posts: 129
• Joined: 07-March 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 02:43 PM

zartek, on 29 May, 2008 - 12:40 PM, said:

the last line of code 'print...'
did not work, though the other conversion equation ounce/16 works just find, can you explain the last line of code to me?

Thanks again

Z

It didn't work? That's strange, it worked in the Try Python online interpreter... (I was at school and couldn't test on a PC with actual Python)

...

Testing my code at home now. The last line is working for me, however pounds = str(ounces/16) isn't. %s is just another way of printing a string variable instead of doing print 'Weight is ", pounds, ' lbs'. It says, "Take %s and fill in the variable _____ for that placeholder", with the variable being the one after the % at the end. It works with multiple variables too. For example...

```var_1 = 'Hello'
var_2 = 'my'
print '%s World, %s name is Andy' % (var_1, var_2)
```

would print "Hello World, my name is Andy".

Sorry I can't help with that line though, as it works for me. What version of Python are you using?

This post has been edited by .Maleficus.: 29 May 2008 - 02:46 PM

### #8 zartek

Reputation: 0
• Posts: 19
• Joined: 29-May 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 02:47 PM

.Maleficus., on 29 May, 2008 - 02:43 PM, said:

zartek, on 29 May, 2008 - 12:40 PM, said:

the last line of code 'print...'
did not work, though the other conversion equation ounce/16 works just find, can you explain the last line of code to me?

Thanks again

Z

It didn't work? That's strange, it worked in the Try Python online interpreter... (I was at school and couldn't test on a PC with actual Python)

...

Testing my code at home now. The last line is working for me, however pounds = str(ounces/16) isn't. %s is just another way of printing a string variable instead of doing print 'Weight is ", pounds, ' lbs'. It says, "Take %s and fill in the variable _____ for that placeholder", with the variable being the one after the % at the end. It works with multiple variables too. For example...

```var_1 = 'Hello'
var_2 = 'my'
print '%s World, %s name is Andy' % (var_1, var_2)
```

would print "Hello World, my name is Andy".

Sorry I can't help with that line though, as it works for me. What version of Python are you using?

actually you can, as you've been a huge help already, can you chat?

### #9 .Maleficus.

Reputation: 2
• Posts: 129
• Joined: 07-March 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 02:58 PM

Sure I guess.

### #10 zartek

Reputation: 0
• Posts: 19
• Joined: 29-May 08

## Re: Converstion Program Equation Help

Posted 29 May 2008 - 09:17 PM

.Maleficus., on 29 May, 2008 - 02:58 PM, said:

Sure I guess.

IM going to PM you my aim/yahoo info

zartek, on 29 May, 2008 - 09:16 PM, said:

.Maleficus., on 29 May, 2008 - 02:58 PM, said:

Sure I guess.

IM going to PM you my aim/yahoo info

actually why dont you send me yours mine is telling me i cant

### #11 .Maleficus.

Reputation: 2
• Posts: 129
• Joined: 07-March 08

## Re: Converstion Program Equation Help

Posted 30 May 2008 - 03:37 AM

I'm pretty sure you need 10 posts to send/receive PMs. Gotta post a little more first .

### #12 zartek

Reputation: 0
• Posts: 19
• Joined: 29-May 08

## Re: Converstion Program Equation Help

Posted 30 May 2008 - 09:24 PM

.Maleficus., on 30 May, 2008 - 03:37 AM, said:

I'm pretty sure you need 10 posts to send/receive PMs. Gotta post a little more first .

oh ok cool thanks man, this site is really dope. i have so many ideas for programs and im anxious to learn alot, i want to work in Xcode eventually. Make apps for the iphone and stuff