Questions tagged [percentage]

Percentage is a ratio or fraction of a quantity that shows the ratio from whole part of quantity. Percentage demonstrates how much is there out of 100.

The ratio or fraction from a quantity that consider out of 100 is called Percentage.

The Percentage is calculate by following formula:

percentage = (part of quantity * 100)/total quantity
2714 questions
17
votes
2 answers

Calculating Percentage value for a Group by value in Postgres

I want to calculate Percentage of a value in Group by. My Table data salesId salesAmount productName salesTyp ------- ----------- ----------- -------- 1 50.00 mouse online 2 100.00 mouse …
Sathesh S
  • 1,253
  • 3
  • 23
  • 54
17
votes
6 answers

Calculating rounded percentage in Shell Script without using "bc"

I'm trying to calculate percentage of certain items in Shell Script. I would like to round off the value, that is, if the result is 59.5, I should expect 60 and not 59. item=30 total=70 percent=$((100*$item/$total)) echo $percent This gives 42.…
user2354302
  • 1,833
  • 5
  • 23
  • 35
17
votes
10 answers

how to calculate percentage in python

This is my program print" Welcome to NLC Boys Hr. Sec. School " a=input("\nEnter the Tamil marks :") b=input("\nEnter the English marks :") c=input("\nEnter the Maths marks :") d=input("\nEnter the Science marks :") e=input("\nEnter the Social…
user3141642
16
votes
3 answers

background-position percentage not working

Everywhere I read says this should be working fine, but for some reason it's not. This was to fix someone else's issue so fixing it doesn't matter to me, I just want to know why. The problem is on .br .bg-image. I know I'm trying to use calc() but…
Jamie Barker
  • 8,145
  • 3
  • 29
  • 64
15
votes
2 answers

Pandas pivot table Percent Calculations

Given the following data frame and pivot table: import pandas as pd df=pd.DataFrame({'A':['x','y','z','x','y','z'], 'B':['one','one','one','two','two','two'], 'C':[2,18,2,8,2,18]}) df A B C 0 x one …
Dance Party2
  • 7,214
  • 17
  • 59
  • 106
15
votes
3 answers

Percentage Based Probability

I have this code snippet: Random rand = new Random(); int chance = rand.Next(1, 101); if (chance <= 25) // probability of 25% { Console.WriteLine("You win"); } else { Console.WriteLine("You lose"); } My question is, does it really…
BlueRay101
  • 1,447
  • 2
  • 18
  • 29
14
votes
4 answers

Get process CPU usage in percentage

The process.cpuUsage() function displays some weird microsecond values. How to get cpu usage in percentage?
Alex
  • 66,732
  • 177
  • 439
  • 641
14
votes
3 answers

Calculating Integer Percentage

So I would like to calculate the percentage progress of my program as the nearest integer value In my examples lets take int FilesProcessed = 42; int TotalFilesToProcess = 153; So First I tried: Int TotalProgress = ((FilesProcessed /…
JKennedy
  • 18,150
  • 17
  • 114
  • 198
14
votes
4 answers

Random value from array by weight in php

I understand that this question has likely been asked, but I don't understand the prior questions enough to know if they do what I want. $fruits = array('20' => 'apple', '40' => 'orange', '40' => 'pear'); The keys are percentages of the chance of…
Drazisil
  • 3,070
  • 4
  • 33
  • 53
13
votes
1 answer

Display the discount percentage on the sale badge in Woocommerce 3

This works for simple products but gives me two errors for variable products. In the sale flash on the archive I get NAN% with error "A non-numeric value encountered". My code: add_filter( 'woocommerce_sale_flash', 'add_percentage_to_sale_bubble'…
user10403192
13
votes
6 answers

safari rounding down on subpixel calculations

i have a container that takes up 829px on a row, and has a background-image of the same size. i have a div within that container that calculates its width based on the 829px container. on safari, the divs width comes out to be something like…
Masu
  • 1,568
  • 4
  • 20
  • 41
12
votes
4 answers

How to force jQuery resizable to use percentage?

I am trying to use the jQuery resizable to resize my div, I've got it to work pretty good except that after the stop event, jQuery UI would revert my % value back to pixel value. I've a working fiddle here:…
codenamezero
  • 2,724
  • 29
  • 64
12
votes
1 answer

jquery animate position in percentage

how do I determine the positions in percentages? $(document).ready(function(){ $("#button").toggle(function(){ $("#slide").animate({top:-100%},1000); },function(){ $("#slide").animate({top:0%},1000); }); …
LGVentura
  • 1,547
  • 1
  • 11
  • 17
11
votes
4 answers

calculate % change in javascript

var current = 12000; var june = 14600; var may = 11200; I want percent change with respect to 'current' month parameter. The output should be in percent and it can add or subtract w.r.t. the current month. How to do this?
Sagar Suryawanshi
  • 195
  • 1
  • 1
  • 11
11
votes
1 answer

percentage width in css not working

I was using a way to define my width property in css with the viewport measurement, css code: #content { position: absolute; background-color: white; width: 100vw; top: 115px; bottom: 30px; display: table; z-index:…
Kevin Ammerlaan
  • 151
  • 1
  • 1
  • 11