How to minus a percentage in python

The simplest way to "subtract 20%" involves no subtraction at all:

>>> x = 10
>>> x *= 0.8          # shorthand for x = x * 0.8
>>> x
8.0

But if for whatever reason you wanted to actually subtract something, here's how:

>>> x = 10
>>> x -= (x * 0.2)    # shorthand for x = (x - (x * 0.2))
>>> x
8.0

Note that this is really more of an algebra/arithmetic question than a coding question.

var valueInString = "2383";

How do I subtract 35% from number and put it back in the variable?

valueInString = valueInString - 35% 

Something like the above?

How to minus a percentage in python

Ry-

212k54 gold badges442 silver badges456 bronze badges

asked May 22, 2013 at 12:44

If I understand you correctly, you want to subtract 35% of valueInString from valueInString. So it is just some basic math.

var valueInString = "2383";
var num = parseFloat(valueInString);
var val = num - (num * .35);
console.log(val);

How to minus a percentage in python

Ry-

212k54 gold badges442 silver badges456 bronze badges

answered May 22, 2013 at 12:51

How to minus a percentage in python

epascarelloepascarello

198k20 gold badges188 silver badges228 bronze badges

2

Math:

valueInString = valueInString * (1 - 0.35);

Shorter:

valueInString *= 1 - 0.35;

answered May 22, 2013 at 12:45

How to minus a percentage in python

Ry-Ry-

212k54 gold badges442 silver badges456 bronze badges

3

A nice little utility function for this would be:

const percentageOff = (
  price: number,
  percentageValue: number
): number => {
  return price * (1 - percentageValue / 100)
}

percentageOff(100, 50); // Output: 50

answered Oct 27, 2020 at 13:36

valueInString = valueInString - ((valueInString * 35) / 100);

How to minus a percentage in python

Ry-

212k54 gold badges442 silver badges456 bronze badges

answered May 22, 2013 at 12:48

1

You have two options if you have to subtract percentages as part of a math problem. With the first method, you work out the percentage value and subtract it from the original value. With the second method, you work out the remaining percentage and then calculate the percentage value. Both methods of subtracting percentages are simple, so just choose the one you prefer.

Calculate, Then Subtract

    Change the percentage to a decimal. For example, say you have a math problem asking you to work out a sale price of an item. The item's original price was $27.90 and it has 30 percent off in the sale. This means you want to subtract 30 percent from $27.90. Divide the percentage number by 100 to convert to a decimal. In this case, work out

    30 ÷ 100 = 0.3

    Multiply the original value by the decimal to determine the percentage value. In this example, work out

    27.90 × 0.3 = 8.37

    Subtract the percentage value from the original price. In this example, work out

    27.90 - 8.37 = 19.53

    The new price is $19.53.

Subtract, Then Calculate

    Take the percentage from 100 to find the remaining percentage. In the previous example, work out

    100 - 30 = 70

    The remaining percentage is 70 percent.

    Divide the remaining percentage number by 100 to convert to a decimal. In this example, work out

    70 ÷ 100 = 0.7

    Multiply the original value by the remaining percentage decimal. In this example, work out

    27.90 × 0.7 = 19.53

    The new price is $19.53.

    Tips

    • If you have a calculator with a percentage (%) key, you can subtract percentages. To subtract 30 percent from $27.90 as per the previous example, type 27.90 − 30 % = to get the answer of 19.53.

How do you minus a percentage?

How to calculate percent off?.
Divide the number by 100 (move the decimal place two places to the left)..
Multiply this new number by the percentage you want to take off..
Subtract the number from step 2 from the original number. This is your percent off number..

How do you take out a percentage in Python?

Use the division / operator to divide one number by another. Multiply the quotient by 100 to get the percentage. The result shows what percent the first number is of the second.

How do you subtract 25 percent from a price?

Percent Off Price Formula.
Convert 25% to a decimal by dividing by 100: 25/100 = 0.25..
Multiply list price by decimal percent: 130*0.25 = 32.50..
Subtract discount amount from list price: 130 - 32.50 = 97.50..
With the formula: 130 - (130*(25/100)) = 130 - (130*0.25) = 130 - 32.50 = 97.50..
25% off $130 is $97.50..

How do you deduct 15 percent from a price?

To subtract 15%, add a negative sign in front of the percentage, and subtract the percentage from 1, using the formula =1-n%, in which n is the percentage. To subtract 15%, use =1-15% as the formula.