Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 105595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:27:50+00:00 2026-05-11T01:27:50+00:00

(code examples are python) Lets assume we have a list of percentages that add

  • 0

(code examples are python)
Lets assume we have a list of percentages that add up to 100:

mylist = [2.0, 7.0, 12.0, 35.0, 21.0, 23.0]   

Some values of mylist may be changed, others must stay fixed.
Lets assume the first 3 (2.0, 7.0, 12.0) must stay fixed and the last three (35.0, 21.0, 23.0) may be changed.

fix = mylist[:3] vari = mylist[3:] 

The goal is to add a new item to mylist, while sum(mylist) stays 100.0 and vari
items keep their relations to each other. For that we need to substract a CERTAIN
PERCENTAGE from each vari item. Example: lets assume we want to add 4.0 to mylist.
Using an ugly aproximation loop I found out that i need to substract ca. 5.0634%
of each vari item (CERTAIN PERCENTAGE = 5.0634):

adjusted =[] for number in vari:     adjusted.append(number-(number*(5.0634/100.0))) adjusted.extend(fix) adjusted.append(4.0) 

adjusted now contains my desired result.

My question is how to calculate CERTAIN PERCENTAGE ;.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:27:51+00:00Added an answer on May 11, 2026 at 1:27 am

    How’s this?

    def adjustAppend( v, n ):     weight= -n/sum(v)     return [ i+i*weight for i in v ] + [n] 

    Given a list of numbers v, append a new number, n. Weight the existing number to keep the sum the same.

     sum(v) == sum( v + [n] ) 

    Each element of v, i, must be reduced by some function of i, r(i) such that

    sum(r(i)) == -n 

    or

    sum( map( r, v ) ) == -n 

    Therefore, the weighting function is -(n*i)/sum(v)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I would suggest using radio buttons as a user will… May 11, 2026 at 11:55 am
  • added an answer Get the book Pragmatic Unit Testing in C# with NUnit… May 11, 2026 at 11:55 am
  • added an answer VisualSVN Server is definitely the way to go. However, you… May 11, 2026 at 11:55 am

Related Questions

(code examples are python) Lets assume we have a list of percentages that add
How are assertions done in c++? Example code is appreciated.
I'm modifying existing security code. The specifications are pretty clear, there is example code,
Are there any tools available that will calculate code metrics (for example number of
Does anyone have any code examples on how to create controllers that have parameters
Can source code examples be kept in a SQL database while retaining all formatting
I'm looking for one line code examples in various languages for getting a valid
Please, provide code examples in a language of your choice. Update : No constraints
I'm doing a PHP site which displays code examples in various languages (C#, PHP,
I am reading a .NET book, and in one of the code examples there

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.