Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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.

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

What is the Norwalk Agreement?

Answered: 1 week ago

Question

=+what effect did this legislation have on money demand? Explain.

Answered: 1 week ago

Question

What is liquidation ?

Answered: 1 week ago

Question

Explain the different types of Mergers.

Answered: 1 week ago

Question

What is dividend payout ratio ?

Answered: 1 week ago