首页 » Python代做 » Python代写 | COMPSCI 101 2021 S1 Assignment 5

Python代写 | COMPSCI 101 2021 S1 Assignment 5

本次新西兰代写主要WiePython基础相关的assignment

Introduction
This assignment first reads a list of colours from a palette text file and creates a dictionary of
colours. The key of each item in the dictionary is the colour code that we will use to draw a pixel
art pattern and the value contains the colour. For example, the pig_palette.txt contains the
following lines:
p:pink
b:black
w:white
d:darkred

and returns a dictionary of colours:
{ ‘p’ : ‘pink’, ‘b’ : ‘black’, ‘w’ : ‘white’, ‘d’ : ‘darkred’}

Next, your program reads lines of Strings from a pattern text file and draws a grid of coloured
rectangles based on the information stored in the text file. Each row of the picture corresponds
to a line in the file, and each rectangle along the row corresponds to a code in the line. For
example, if the colour codes that we read from the above palette file are b: brown, c: bisque,
w: white, p: purple, t: tan, the following table shows the contents of the pattern file,
“steve.txt” and the corresponding pixel art. The first row (bbbbbbbb) represents 8 brown
rectangles.

Part 1: CodeRunner section: [20 marks]
 Complete the first three functions in CodeRunner and copy into the A5CreatePattern.py
file to create a colour palette file.
 Complete the last three functions in CodeRunner and copy into your A5.py file to read the
colour palette file and pixel pattern file.

Part 2: The Final Program [10 marks]
Complete the A5 program so that it draws a pixel art pattern according to the filename entered
by the user. Steps:
 Copy the solution of the last three functions from CodeRunner into the A5.py file
 Add your username to the title bar of the window. Currently the title bar of the program
window displays “A5 by”. Add your username to the title bar of the program (e.g. A5 by
kng001).
 Add a docstring at the top of the file containing your name, username and a description of
the program.
 Complete the draw_pattern(a_canvas, colour_dictionary, pattern_list, size, start_x,
start_y) function

The draw_pattern function is passed SIX parameters: the Canvas object, a colour dictionary,
a list of String elements, and three integer parameters. The function draws a grid of
coloured rectangles inside the canvas area. The left-top position of the grid of coloured
rectangles is given by the last two parameter values and the size of each rectangle is given
by the size parameter.

Optional: Create your own palette and pattern text files
Your pattern should show great preparation, creativity or effort. Email your text files to Angela
(angela@cs.auckland.ac.nz). Some examples are given as below:


程序辅导定制C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持 Alipay WeChatPay PayPal等支付方式

E-mail: vipdue@outlook.com  微信号:vipnxx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

blank