Results 1 to 8 of 8

Math Help - How to find the percentage number?

  1. #1
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    4
    Thanks
    1

    How to find the percentage number?

    Hi all.

    I'm trying to find a percentage of a number but getting a lot of weird answers.

    I'm learning programming so I'll try and keep it in its format.

    gdp = 100
    spending = 5 (this is 5%, I want to be able to find how much this percentage is)

    How would I do this? I've tried (gdp / spending) * 100 but that gave an answer like 0.0000033666.

    Can someone please help?

    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member BAdhi's Avatar
    Joined
    Oct 2010
    From
    Gampaha, Sri Lanka
    Posts
    252
    Thanks
    6

    Re: How to find the percentage number?

    Can you post the code or part of the code that you've tried because as per your given information I don't think there is a way of getting that weird answer
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    4
    Thanks
    1

    Re: How to find the percentage number?

    Code:
    gdp = 0
    spending = 0
    gdpinput = int(input("Enter your countries GDP: ")) This lets the user input the country's gdp
    spending = int(input("Enter the spending % of gdp (ex. 0.03 for 3%): ")) This asks the user to input the country's spending
    budget = (gdpinput / spending) * 100 This was my failed calculation
    
    print(budget)
    Sorry if this is confusing, I'm just trying to figure out how to find how much money is in the percentage. Say the user inputs 30% of gdp spending, I'd like to figure out how much that 30% is.

    Thanks

    EDIT:

    I think I've figured it out.

    I changed

    Code:
    budget = (gdpinput / spending) * 100
    to this

    Code:
    budget = (gdpinput * spending) / 100
    Last edited by Amalur; August 6th 2012 at 09:25 AM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,530
    Thanks
    774

    Re: How to find the percentage number?

    If, say, gdpinput is in dollars, then (gdpinput * spending) is the dollar value of spending. I am not sure how to describe (gdpinput * spending) / 100 other than 1/100th of the dollar value of spending.

    If spending is the actual fraction, say, 0.03, then spending * 100 is the same fraction expressed as percents; in this case, 3%. But if x is a dollar value, then x / 100 is in no way the same value.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    4
    Thanks
    1

    Re: How to find the percentage number?

    I'm confused, does that mean I'm wrong?
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,530
    Thanks
    774

    Re: How to find the percentage number?

    Quote Originally Posted by Amalur View Post
    I'm confused, does that mean I'm wrong?
    Yes if the variable spending contains an actual fraction (not expressed in percents), which is what your code says.

    Why don't you make several test input/output values and see if you code works correctly. Say, for your example in post #1 where gdp is 100 and spending is 0.05, what should the budget be?
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Aug 2012
    From
    Canada
    Posts
    4
    Thanks
    1

    Re: How to find the percentage number?

    I get 0.05. Isn't that correct? 0.05% of 100 is 0.05 (I hope)
    Follow Math Help Forum on Facebook and Google+

  8. #8
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,530
    Thanks
    774

    Re: How to find the percentage number?

    Quote Originally Posted by Amalur View Post
    0.05% of 100 is 0.05 (I hope)
    That is correct. However, it is not clear how you enter 0.05%. Your code asks to enter it as a fraction not expressed in percents, i.e., as 0.0005. In this case, 100 * 0.0005 = 0.05 and no division by 100 is necessary. (This is not to mention that your example from post #1 had spending equal to 5%, or 0.05 and not 0.05%.)

    If you enter spending in percents, then budget = gdpinput * spending / 100.
    If you enter spending as an actual fraction (not in percents), then budget = gdpinput * spending.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Percentage: given a certain number...
    Posted in the Algebra Forum
    Replies: 2
    Last Post: August 9th 2011, 11:23 PM
  2. Replies: 4
    Last Post: June 27th 2011, 08:25 PM
  3. percentage % of a number
    Posted in the Algebra Forum
    Replies: 3
    Last Post: March 24th 2009, 04:58 AM
  4. translate number range to percentage
    Posted in the Pre-Calculus Forum
    Replies: 1
    Last Post: March 12th 2008, 10:56 AM
  5. translate number range to percentage
    Posted in the Statistics Forum
    Replies: 1
    Last Post: March 12th 2008, 10:52 AM

Search Tags


/mathhelpforum @mathhelpforum