Question
This is two parts of a multi-step program regarding an election vote on PYTHON 1 def normalisePaper(p, n): # sum(p) > 0 normalisePaper(p, n) returns
This is two parts of a multi-step program regarding an election vote on PYTHON
1 def normalisePaper(p, n): # sum(p) > 0 normalisePaper(p, n) returns p with each vote scaled according to its total, and padded to contain n votes. For example: normalisePaper([1,2,3,4], 4) = [0.1, 0.2, 0.3, 0.4], normalisePaper([2], 3) = [1.0, 0.0, 0.0], normalisePaper([0, 4, 496], 3) = [0.000, 0.008, 0.992]
2 def normalisePapers(ps, n): # for every p on ps, sum(p) > 0 normalisePapers(ps, n) returns ps with each paper normalised, in an election with n candidates. e.g. normalisePapers([[2], [7, 2, 1]], 3) = [[1.0, 0.0, 0.0], [0.7, 0.2, 0.1]].
This is my code that works fine on the examples:
How ever when reading a file into a main function(compiled of other functions), these errors occur. I think this might be due to some lines of the file has words in it. But i'm not too sure.
def normalisePaper (p,n) sum for vote in p: for i in range (len (p)) while len (p)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started