How to design reusable code segments via planned function

Assignment Help Python Programming
Reference no: EM132369735

Assignment Part A: Tessellation

Motivation

One of the most basic functions of any IT system is to process a given data set to produce some form of human-readable output. This assignment requires you to produce a visual image by following instructions stored in a list. It tests your abilities to:

• Process lists of data values;

• Produce maintainable, reusable code;

• Design a solution to a repetitive computational problem; and

• Display information in a visual form.

In particular, you will need to think carefully about how to design reusable code segments, via well-planned function definitions and the use of repetition, to make the resulting program concise and easy to understand and maintain.

Goal

Completely filling a plane with tiles of different shapes is a computational challenge that goes back to ancient times. Formally this process is called “tessellation”. In this assignment you will solve this challenge by drawing “tiles” (rectangular images) in a grid using automatically-generated solutions. To do so you must follow a set of instructions, provided as a Python list, to place differently-sized tiles in various locations in the grid. When this is done properly the grid will be entirely filled with non-overlapping tiles. Most importantly, the pattern to be followed is generated randomly, so your solution must be sufficiently general that it can work correctly for any possible pattern of tiles that fills the grid.

Designing the tiles

To complete this assignment you must design four entirely distinct tiles which can be used to fill the grid. There must be one tile in each of four required shapes: 2 ´ 2, 1 ´ 2, 2 ´ 1 and 1 ´ 1 grid squares. Each tile must fit exactly into the required number of 100 ´ 100 pixel squares. Each tile must contain a single image, different from the other tiles, and which fills its whole area. They must be drawn using Turtle graphics primitives only, must be easily recognisable, must be of a reasonable degree of complexity, involving multiple Turtle shapes, and must all be part of some common theme. You have a free choice of theme and are encouraged to be imaginative!

Some possible themes you may consider are:

• Cartoon or comic characters

• TV or movie characters

• Sporting teams

Businesses (banks, restaurants, IT companies, etc)

• Computer or board games (e.g., Monopoly tokens)

• Internet or cloud service providers

• Geographical sites (cities, countries or tourist attractions)

• Vehicles (cars, boats, planes, etc)

• Household objects

• Or anything else suitable for creating four distinct and easily-identifiable tiles

Data format

The random_pattern function used to assess your solution returns a list of “instructions” representing the places to draw each tile and the kind of tile to draw. Each of the instructions is itself expressed as a list containing two to five character strings, depending on the shape of
tile. Their general form is as follows:

[squares, mystery_value]

There may be one, two or four grid squares listed at the beginning. Each square is described as an x-y grid coordinate expressed as a letter and a digit. The list of squares tells us which grid squares must be filled by this particular tile. This information also tells us which shape of tile to produce:

• a “big” tile will occupy four grid squares;

• a “small” tile will occupy one square;

• a “wide” tile will occupy two squares in the same row; and

• a “tall” tile will occupy two squares in the same column.

The purpose of the “mystery value”, which is always either ‘O’ or ‘X’, will be revealed in Part B of the assignment.

For instance, instruction

['C5', 'O']

tells us to draw a “small” tile, occupying a single square, at grid location C5. Instruction

['H5', 'I5', 'X']

says to draw a “wide” tile, occupying two squares in the same row, spanning grid locations

H5 and I5. Similarly, instruction

['E1', 'E2', 'O']

tells us to draw a “tall” tile, occupying squares E1 and E2 in the same column. Finally, instruction

['E5', 'F5', 'E6', 'F6', 'X']

specifies drawing a “big” tile, occupying four squares, E5, F5, E6 and F6, spanning two rows and two columns. The random_pattern function generates a list of such instructions which, when followed completely, fills every square in the grid with non-overlapping tiles. In addition to the random_pattern function, the template file also contains a number of “fixed” data sets.

These are provided to help you develop your code, so that you can work with a known pattern while debugging your code. However, the “fixed” patterns will not be used for assessing your solution. Your tessellate function must work correctly for any pattern randomly generated by function random_pattern.

Requirements

To complete this part of the assignment you are required to extend the provided tessellation.py Python file by completing function tessellate so that it can draw tiles as specified by the data sets generated by the random_pattern function. Your tessellate function must work correctly for all possible values returned by the random_pattern function.

Your submitted solution will consist of a single Python 3 file, and must satisfy the following criteria.

1. Drawing four entirely distinct tiles within a common theme (6%). Your program must be able to draw four clearly distinct tiles, each containing a single image different from the other tiles, in each of the four required shapes (2 ´ 2, 1 ´ 2, 2 ´ 1 and 1 ´ 1 squares), and each fitting exactly into the required number of 100 ´ 100 pixel squares.

Each tile’s image must be clearly recognisable, must be of a reasonable degree of complexity, involving multiple Turtle shapes, and must entirely fill the tile’s area but without going outside the specified area. It must be easy to distinguish each tile from those adjacent to it through the use of distinct colours and/or borders.

2. Identifying the theme and tiles (3%). When executed your code must draw a “legend” on the left and right of the canvas which clearly describes your theme and indicates the meaning/identity of each of the four tiles. The legend must include a visual copy of each tile and text describing it. You must also put a title at the top of the Turtle drawing canvas describing your theme and tiles.

3. Placing tiles in the grid as per any given pattern (8%). Your code must be capable of drawing tiles to fill the grid, exactly as dictated by any valid data set provided to function tessellate. The tiles must be positioned precisely within the grid squares corresponding to the pattern described. The drawings of the tiles must preserve their integrity no matter where they are drawn, with no spurious additional or missing lines. Your solution for drawing the tiles must work correctly for any values returned by the random_pattern function.

4. Code quality and presentation . Your program code, for both Parts A and B of the assignment, must be presented in a professional manner. See the coding guidelines in the IFB104 Code Presentation Guide (on Blackboard under Assessment) for suggestions on how to achieve this. In particular, given the obscure and repetitive nature of the code needed to draw complex images using Turtle graphics, each significant code segment must be clearly commented to say what it does.

Similarly, the names of your functions, parameters and variables should be indicative of their purpose, not just “i”, “j”, etc. Also, you must use function definitions and loops to avoid unnecessary duplication of similar or identical code segments. To get full marks for this criterion you must provide a significant amount of code to assess.

5. Extra feature (4%). Part B of this assignment will require you to make a last-minute extension to your solution. The instructions for Part B will not be released until shortly before the final deadline for Assignment 1.

You must complete the assignment using basic Turtle graphics, random number and maths functions only. You may not import any additional modules or files into your program other than those already included in the given tessellation.py template. In particular, you may not import any image files for use in creating your drawing.

Finally, you are not required to copy the example shown in this document. Instead you are strongly encouraged to be creative in the design of your solution. Surprise us!

Assignment Part B: Broken Tiles

Motivation

One of the most common tasks in “Building IT Systems” is modifying some existing code.

In practice, computer programs are written only once but are subsequently modified and extended many times during their operational lifetime. Code changes may be required in response to internal factors, such as the need to correct design flaws or coding errors, or external factors, such as changes in consumer requirements.

A common situation is where some new feature must be added to an existing program. This is the scenario simulated in this part of the assignment. This task requires you to extend your solution to Part A of the assignment by adding an additional feature. It tests:

• Your ability to work under time pressure; and

• The quality and clarity of your code for Part A, because a well-written solution to Part A will make completing this part of the assignment easy.

Goal

In Part A of this assignment you were required to develop a program which could follow instructions, encoded as a randomly-generated Python list, to draw a pattern of differentlyshaped tiles that precisely filled a rectangular area. However, one of the frustrations of “tessellation” using real ceramic tiles is that they can become cracked or broken, spoiling the pattern. In this part of the assignment you will simulate this annoying, but realistic, situation.

Specifically:

• For each of your four different types of tiles you must develop a “broken” version; and

• You must draw a broken tile for any instruction in the pattern that ends with an ‘X’.

To complete this additional task you must extend your solution to Part A. No additional Python template file is supplied for this part. As per

Part A, your Part B solution must work for any randomly-generated pattern that can be returned by the provided function random_pattern.

Requirements and marking guide

To complete this task you are required to extend your Part A tessellation.py file by adding code so that as well as drawing the pattern of tiles and the legend, you show any tiles with an ‘X’ in their broken form.

Your submitted solution for both Parts A and B will consist of a single Python file. Your Part B extension must satisfy the following criteria. Marks available are as shown.

1. Drawing broken tiles (2%). All four types of tiles can be drawn in “broken” form, with a realistic image of damage on top of the original image. The damage to each tile must be drawn using basic Turtle graphics shapes and must be of a reasonable degree of complexity, involving several lines and not, for instance, just one or two straight lines. The “damage” must be obvious and must cover the majority of the tile’s surface.2. Tiles marked with an ‘X’ are broken (2%). Your program must draw a broken version of a tile for every instruction that ends with an ‘X’. All other tiles (those ending with an ‘O’) must be drawn in their unbroken form.

You must complete the assignment using basic Turtle graphics and maths functions only.

You may not import any additional modules or files into your program other than those already included in the given tessellation.py template. In particular, you may not use any image files in your solution.

Attachment:- Assignment Details.rar

Reference no: EM132369735

Questions Cloud

On what basis might barnard be liable on the trustmark notes : On what basis might Barnard be liable on the Trustmark notes? Would he be primarily or secondarily liable? Could this liability be discharged on the theory.
Supply chain network design : Support for growth of the Indian chemical market. Financial results, including profit and capital expenditures-assume the cost of a new plant is $200 millio
Advise the city sky co of the input tax credit entitlements : Advise The City Sky Co of the input tax credit entitlements that they may be entitled to. Assume that The City Sky Co is registered for GST purposes
Discuss difficulties of performing backups in organizations : Discuss the difficulties of performing backups in organizations that have a 24/7 business processing day. What options are available? What are the advantages.
How to design reusable code segments via planned function : IFB104 Building IT Systems-Queensland University of Technology-Australia- How to design reusable code segments, via well-planned function definitions.
Explain what are the issue of securing backups : Discuss the issue of securing backups. There have been several incidents lately in which backup media containing personal customer information were lost.
What sort of attacks might take place : You are the web master for the Republican Party National Committee. Prepare a risk assessment analysis for your website. Some questions to consider.
Corporate social responsibility and financial performance : Analyze the organization's performance in these dimensions: environmental sustainability, corporate social responsibility, and financial performance.
Define compliance issues that the company may encounter : ISOL533 - Using your reading in Chapter 4 as a guide and the threats that were listed in the Project Overview, write a 2 - 3 page paper that addresses.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a Python script that allows the user to enter a number

COMS 104 Introduction to Programming Assignment, Iowa State University, USA. Write a Python script that allows the user to enter a number greater than 100

  Generate a random ordered list of integers

In Python, the use the binary search functions given(recursive and iterative). Generate a random ordered list of integers and do a benchmark analysis.

  Construct confidence interval for population proportion

Construct a 99% confidence interval for the proportion of days with solar power generation above 43 kWh for City A.

  Explain the differences between a variable and data types

Explain the differences between a variable and data types. What other source did you find that helped you improve your understanding of Python Programming.

  Write a program to solve a simple payroll calculation

Write a program to solve a simple payroll calculation. Find the amount of pay given, hours worked, and hourly rate. Display hourly rate, hours worked, and pay.

  Write a program that asks the user to enter a name

Asks the user to enter a name, age, and sex and allow the user to enter data for individuals as long as they would like provide them.

  Design part of the code for the haunted house game

Create a cheat commands in the game so player can teleport to any location in the map - You are tasked with improving and designing part of the code for the Haunted House game.

  Write a function which expects one argument and the name

Write a function called days which expects one argument, the name of a month as a string, and returns the number of days in that month as given in the rhyme.

  Write a python program that prompts the for the name

Write a PYTHON program that prompts the user for the name of the item and the price of each item, and then simply displays whatever the user typed.

  A program that accepts a comma separated sequence of words

Write a program that accepts a comma separated sequence of words as input and prints the words in a comma-separated sequence after sorting them.

  Apply struct for reading packet data

Topic: Python 3 - PCAP file analysis - Apply struct for reading packet's data, extract and hash the ICMP data portion of the packet

  Python script that reads and analyses child mortality data

ICT702 - Data Wrangling - Write a Python script that reads and analyses the child mortality data - Use Python to combine the child mortality data

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd