代做comp9021 olygons Python Assignment 2, Trimester 3, 2024帮做Python编程

comp9021 olygons Python

Assignment 2 , Trimester 3, 2024

1. General matter

1.1. Aims. The purpose of the assignment is to:

· design and implement an interface based on the desired behaviour of an application program;

· practice the use of Python syntax;

· develop problem solving skills.

1.2. Submission. Your program will be stored in a file n amed p olygons.py. A fter y ou h ave d eveloped andtested your program, upload it using Ed (unless you worked directly in Ed). Assignments can be submittedmore than once; the last version is marked. Your assignment is due by November 11, 9:00am.

1.3. Assessment. The assignment is worth 13 marks. It is going to be tested against a number of input files.For each test, the automarking script. will let your program run for 30 seconds.Assignments can be submitted up to 5 days after the deadline. The maximum mark obtainable reduces by5% per full late day, for up to 5 days. Thus if students A and B hand in assignments worth 12 and 11, bothtwo days late (that is, more than 24 hours late and no more than 48 hours late), then the maximum markobtainable is 11.7, so A gets min(11.7, 11) = 11 and B gets min(11.7, 11) = 11. The outputs of your programsshould be exactly as indicated.1.4. Reminder on plagiarism policy. You are permitted, indeed encouraged, to discuss ways to solve theassignment with other people. Such discussions must be in terms of algorithms, not code. But you mustimplement the solution on your own. Submissions are routinely scanned for similarities that occur when studentscopy and modify other people’s work, or work very closely together on a single implementation. Severe penaltiesapply.

1. General presentationYou will design and implement a program that will

· extract and analyse the various characteristics of (simple) polygons, their contours being coded andstored in a file, and

– either display those characteristics: perimeter, area, convexity, number of rotations that keep thepolygon invariant, and depth (the length of the longest chain of enclosing polygons)– or output some Latex code, to be stored in a file, from which a pictorialrepresentation of thepolygons can be produced, coloured in a way which is proportional to their area.

Call encoding any 2-dimensional grid of size between between 2 × 2 and 50 × 50 (both dimensions can bedifferent) all of whose elements are either 0 or 1.Call neighbour of a member of an encoding any of the at most eight members of the grid whose value is 1and each of both indexes differs from m’s corresponding index by at most 1. Given a particular encoding, weinductively define for all natural numbers the set of polygons of depth d (for this encoding) as follows. Let anatural number be given, and suppose that for all d 0 < d, the set of polygons of depth d 0 has been defined.Change in the encoding all 1’s that determine those polygons to 0. Then the set of polygons of depth isdefined as the set of polygons which can be obtained from that encoding by connecting 1’s with some of theirneighbours in such a way that we obtain a maximal polygon (that is, a polygon which is not included in anyother polygon obtained from that encoding by connecting 1’s with some of their neighbours).12>>> polys.display()The effect of executing polys.display() is to produce a file named polys_4.tex that can be given asargument to pdflatex to produce a file named polys_4.pdf that views as follows.20

1. Detailed description

4.1. Input. The input is expected to consist of ydim lines of xdim 0’s and 1’s, where xdim and ydim are atleast equal to 2 and at most equal to 50, with possibly lines consisting of spaces only that will be ignored andwith possibly spaces anywhere on the lines with digits. If isthe th digit of the th line with digits, with

≤ x < xdim and 0 ≤ y < ydim , then is to be associated with a point situated x × 0.4 cm to the right andy × 0.4 cm below an origin4.2. Output. Consider executing from the Python prompt the statement from polygons import * followedby the statement polys = Polygons(some_filename). In case some_filename does not exist in the workingdirectory, then Python will raise a FileNotFoundError exception, that does not need to be caught. Assumthat some_filename does exist (in the working directory). If the input is incorrect in that it does not containonly 0’s and 1’a besides spaces, or in that it contains either too few or too manylines of digits, or in thasome line of digits contains too many or too few digits, or in that two of its lines of digits do not contain thesame number of digits, then the effect of executing polys = Polygons(some_filename) should be to generate

a PolygonsError exception that reads

Traceback (most recent call last):

...polygons.PolygonsError: Incorrect input.If the previous conditions hold but it is not possible to use all 1’s in the input and make them the contoursof polygons of depth d, for any natural number d, as defined in the general presentation, then the effect ofexecuting polys = Polygons(some_filename) should be to generate a PolygonsError exception that readsTraceback (most recent call last):

...polygons.PolygonsError: Cannot get polygons代写comp9021 olygons   Python   as expected.If the input is correct and it is possible to use all 1’s in the input and make them the contours of polygonsof depth d, for any natural number d, as defined in the general presentation, then executing the statementpolys = Polygons(some_filename) followed by polys.analyse() should have the effect of outputting a firstline that readsPolygon N:with N an appropriate integer at least equal to 1 to refer to the N’th polygon listed in the order of polygons

highest point from smallest value of to largest value of y, and for a given value of y, from smallest valueof to largest value of x, a second line that reads one ofPerimeter: a + b*sqrt(.32)Perimeter: aPerimeter: b*sqrt(.32)

with a an appropriate strictly positive floating point number with 1 digit after the decimal point and b anappropriate strictly positive integer, a third line that readsArea:with a an appropriate floating point number with 2 digits after the decimal point, a fourth line that reads oneofConvex: yesConvex: nofifth line that readsNb of invariant rotations: N21with N an appropriate integer at least equal to 1, and a sixth line that readsDepth: Nwith N an appropriate positive integer (possibly 0)Pay attention to the expected format, including spaces.If the input is correct and it is possible to use all 1’s in the input and make them the contours of polygons of depth d, for any natural number d, as defined in the general presentation, then executing the statement polys = Polygons(some_filename) followed by .display() should have the effect of produc ing a file named some_filename.tex that can be given as argument to pdflatex to generate a file namesome_filename.pdf. The provided examples will show you what some_filename.tex should contain.

· Polygons are drawn from lowest to highest depth, and for a given depth, the same ordering as previouslydescribed is used.

· The point that determines the polygon index is used as a starting point in drawing the line segmentsthat make up the polygon, in a clockwise manner.

· A polygons’s colour is determined by its area. The largest polygons are yellow. The smallest polygonsare orange. Polygons in-between mix orange and yellow in proportion of their area. For instance, apolygon whose size is 25% the difference of the size between the largest and the smallest polygon willreceive 25% of orange (and 75% of yellow). That proportion is computed as an integer. When the valueis not an integer, it is rounded to the closest integer, with values of the form. z.5 rounded up to + 1.Pay attention to the expected format, including spaces and blank lines. Lines that start with % are comments.The output of your program redirected to a file will be compared with the expected output saved in a file (of adifferent name of course) using the diff command. For yourprogram to pass the associated test, diff shouldsilently exit, which requires that the contents of both files be absolutely identical, character for character,including spaces and blank lines. Check your program on the provided examples using the associated .tex files,renaming them as they have the names of the files expected to be generated by your program.


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图