P5 Division P5 DIVISION Directions. Name your scripts 253-yourlastname-?-?.py . For example, my submission for P3 problem 4 would be a file 253-pauli-3-4.py . Each project script should be uploaded to...

Python division algorithm help


P5 Division P5 DIVISION Directions. Name your scripts 253-yourlastname-?-?.py . For example, my submission for P3 problem 4 would be a file 253-pauli-3-4.py . Each project script should be uploaded to Canvas by clicking the assignment. The Python Tutorial (PT) is available at http://docs.python.org/py3k/tutorial/ the Non-Programmer’s Tutorial for Python 3 (NP) is available at http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3 (1) (PT) Read and work through the examples in §4.7.1: Default Argument Values (2) Write a script that contains the following. For each part, first print the number to make it easier to grade. You may use %, //, /, and divmod only to verify the correctness of your functions. (a) Implement the division algorithm for positive divisors as a function quorem_pos(a,m,verbose=False) where a ≥ 0 and m > 0 are integers. The return values are integers q and 0 ≤ r < m="" such="" that="" a="q" ·m="" +="" r.="" print="" the="" values="" of="" the="" variables="" in="" each="" iteration="" of="" the="" loop="" when="" verbose="True." (b)="" implement="" the="" division="" algorithm="" for="" positive="" divisors="" as="" a="" function="" quorem_neg(b,m,verbose="False)" where="" b="">< 0="" and="" m=""> 0 are integers. The return values are integers q and 0 ≤ r < m="" such="" that="" a="q" ·m="" +="" r.="" print="" the="" values="" of="" the="" variables="" in="" each="" iteration="" of="" the="" loop="" when="" verbose="True." (c)="" the="" function="" quorem(a,m,verbose="False)" where="" b="" and="" m=""> 0 are integers that calls quorem_pos or quorem_neg and returns integers q and 0 ≤ r < m such that a = q ·m+ r. print the values of the variables in each iteration of the loop when verbose=true. (d) the function mod(a,m) that calls quorem to return a mod m. (e) the function div(a,m) that calls quorem ro return the integer quotient of the division of a and m. (f) the function are_congruent(a,b,m) that returns true if a ≡ b mod m and false otherwise. call any of the functions above. (g) test each of the functions above with 6 different combinations of arguments (including the optional argument verbose). rubric 10–9 pts: script runs without errors. all required components are correctly addressed. the difference between 9 and 10 comes from coding style (comments, structure) and writing style (grammar and spelling in responses). 8–6 pts: script runs without errors but some required component is missing or incor- rect. the score in this range depends on the what is missed. 5 pts: script does not run because of errors. 0 pts: no submission. 1 http://docs.python.org/py3k/tutorial/ http://docs.python.org/py3k/tutorial/ http://en.wikibooks.org/wiki/non-programmer%27s_tutorial_for_python_3 http://en.wikibooks.org/wiki/non-programmer%27s_tutorial_for_python_3 http://docs.python.org/py3k/tutorial/ m="" such="" that="" a="q" ·m+="" r.="" print="" the="" values="" of="" the="" variables="" in="" each="" iteration="" of="" the="" loop="" when="" verbose="True." (d)="" the="" function="" mod(a,m)="" that="" calls="" quorem="" to="" return="" a="" mod="" m.="" (e)="" the="" function="" div(a,m)="" that="" calls="" quorem="" ro="" return="" the="" integer="" quotient="" of="" the="" division="" of="" a="" and="" m.="" (f)="" the="" function="" are_congruent(a,b,m)="" that="" returns="" true="" if="" a="" ≡="" b="" mod="" m="" and="" false="" otherwise.="" call="" any="" of="" the="" functions="" above.="" (g)="" test="" each="" of="" the="" functions="" above="" with="" 6="" different="" combinations="" of="" arguments="" (including="" the="" optional="" argument="" verbose).="" rubric="" 10–9="" pts:="" script="" runs="" without="" errors.="" all="" required="" components="" are="" correctly="" addressed.="" the="" difference="" between="" 9="" and="" 10="" comes="" from="" coding="" style="" (comments,="" structure)="" and="" writing="" style="" (grammar="" and="" spelling="" in="" responses).="" 8–6="" pts:="" script="" runs="" without="" errors="" but="" some="" required="" component="" is="" missing="" or="" incor-="" rect.="" the="" score="" in="" this="" range="" depends="" on="" the="" what="" is="" missed.="" 5="" pts:="" script="" does="" not="" run="" because="" of="" errors.="" 0="" pts:="" no="" submission.="" 1="" http://docs.python.org/py3k/tutorial/="" http://docs.python.org/py3k/tutorial/="" http://en.wikibooks.org/wiki/non-programmer%27s_tutorial_for_python_3="" http://en.wikibooks.org/wiki/non-programmer%27s_tutorial_for_python_3="">
Mar 04, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here