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:

This is two parts of a multi-step program regarding an election vote

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.

on PYTHON 1 def normalisePaper(p, n): # sum(p) > 0 normalisePaper(p, n)

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!