[SOLVED] 代写 data structure html python shell graph CSE 231 Programming Project 02 Spring 2019

30 $

File Name: 代写_data_structure_html_python_shell_graph_CSE_231_Programming_Project_02_Spring_2019.zip
File Size: 828.96 KB

SKU: 4240825615 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


CSE 231 Programming Project 02 Spring 2019
Assignment Overview
This project focuses on rendering different colors and some simple graphics using Python libraries. You will use both selection (if) and repetition (while, for) in this project. This assignment is worth 20 points (2% of the course grade) and must be completed and turned in before 11:59 PM on Monday, January 21, 2019.
You will use Turtle graphics to draw a picture containing multiple shapes of multiple colors and arranged to be visually pleasing. Although you are free to decide the precise shape(s) and layout for your picture, some aspect of the picture must depend on a numeric value input by the user. For example, the input might determine the size of the shapes, the number of shapes, or their spacing.
Background
Originally written as a part of the logo programming language, Turtle graphics (http://en.wikipedia.org/wiki/Turtle_graphics) is one of the oldest graphics programs. It is a 2D graphics package that uses a Cartesian coordinate system and a “turtle,” which you can imagine has
a pen attached to its body. The turtle can move around the plane, drawing as it goes. Python has a module that implements the behavior of the original turtle graphics program and this module is simply called “turtle” (see Appendix B of the text and the comments in the sample file turtleSample.py).
Project Description / Specification
Your program must:
1. Output a brief descriptive message of what the program does.
2. The program should prompt the user to choose between 2 options until the user enters 0 :
a. 0 to quit
b. 1 for circles
c. 2 for filled square spirals
3. On invalid input, the program should display an error message and reprompt.
4. If the user enters 1 , draw a picture containing multiple filled concentric circles of multiple
colors. Repeatedly prompt for the input until the user supplies values of the correct form (discard incorrect inputs). Your prompt should say what form of input is needed.
a. Input the number of circles to draw (greater than 1)
b. Input the radius of the largest circle. It must be between 50 and 200
5. If the user enters 2 , draw a picture containing multiple filled squares in a spiral of multiple
colors. The number of squares is an input that must be higher than 1. Repeatedly prompt for the input until the user supplies value of the correct form. Your prompt should say what form of input is needed.
a. Input the number of squares to draw (greater than 1)
b. Input the side of the squares. It must be between 50 and 200 6. turtle.clear() is useful before drawing the next figure.
7. If the user enter 0 , the program should exit.
In programming your solution, you must:
1. Use at least two repetition (while or for) statements. 2. Use at least one selection (if) statement.

We show example output produced by two different programs that meet these requirements at the end of this write-up. You may be creative and create your own program, or you may choose to mimic these three examples. The second example shows error checking being tested.
Deliverables
proj02.py – your source code solution. Be sure to use “proj02.py” for the file name on Mimir. Notes and Hints:
1. Do error checking on input last, i.e. after the rest of the program is working.
2. Items 1-6 of the Coding Standard will be enforced for this project.
3. You are not allowed to use advanced data structures such as list, dictionaries, classes‚ etc.
4. Hard coding will result in a score of zero. That is, if you tailor your solution to only work
for the test cases instead of working for general cases, you will receive a score of zero.
5. Reminder: programming projects are individual assignments, not to be done collaboratively
with other students. See the syllabus for details.
Creating Colors:
There are many ways to create a color but a common one used in computer graphics is the process of additive color (see http://en.wikipedia.org/wiki/Additive_color). Combining different amounts of red, green and blue can create most (but not all) colors. In turtle, you can specify a color by giving three floating-point values, each in the range from 0.0 to 1.0, indicating the amount (fraction or percent) of each color. For instance, (1.0, 0.0, 0.0) is red, (0.0, 1.0, 0.0) is green, and (0.5, 0.5, 0.0) is brown. You can find the codes for many colors on a color chart (e.g, “% code” column on http://www.december.com/html/spec/colorcodes.html).
A convenient way to generate different colors is to repeatedly call the random function in the random module to obtain values for the color amounts. First, import the random module: import random Then, each call to random.random() returns a pseudo random (floating-point) number in the range 0.0 to 1.0. A sample program using this method to create a color and draw a figure is provided in the project directory: turtleSample.py
Using turtle graphics:
In order to use turtle graphics in Python you must first import the turtle module. You can then use the help function in Idle to find out what methods this module includes and what they do. Just type import turtle in the Python Shell window, hit enter, and then type help(turtle) and scroll up through the list and information. For more details Google “Python 3 turtle.” A sample Python program, turtleSample.py, is provided in the project directory. The comments in this file describe methods that you might want to use for this project. When running your program in Idle, you may need to look under the other Idle windows to find the turtle drawing window.
Keeping the window up
If the drawing window has a tendency to disappear too quickly, you can “hold” the window by using the sleep function in the time module, as follows:
import time
time.sleep(seconds)
The program will wait the number of seconds indicated before it ends. Once the program is fully developed waiting for the selection to quit will naturally keep the window open.

Working nicely in an IDE
Some IDEs such as Spyder do not work well with other graphics windows. If you have trouble with windows hanging (freezing) at the end of the program, you can use the _exit function in the os module. (I had this problem on a Mac.)
import os
os._exit(1)
Note the underline in the name. Make the call to the _exit function the last line in the program.
Test 1:
To illustrate, we show results of executing three programs, all of which meet the requirements.
The first program draws concentric circles of many colors. The user specifies the number of circles and the radius of the largest circle.
An example interaction:
What do you want to draw:
(0) to quit
(1) circles
(2) square spiral.
choice: 1
This program draws concentric circles of many different colors.
Enter the number of circles to draw: -1
Number of circles must be positive; try again.
Enter the number of circles to draw: 8
Enter the radius (>=50, <=200) of the largest circle: 25The radius must be an integer between 50 and 200; try again.Enter the radius (>=50, <=200) of the largest circle: 150 What do you want to draw: (0) to quit (1) circles (2) square spiral.choice: 2This program draws squares of many colors.Enter the number of squares to draw: 0Number of squares must be positive; try again.Enter the number of squares to draw: 9Enter the side length (>=50, <=200) of the largest square: 50 What do you want to draw: (0) to quit (1) circles (2) square spiral.choice: 3Invalid choice; try again.What do you want to draw: (0) to quit (1) circles (2) square spiral.choice: 0Grading rubrics:General Requirements______ 4 ptsCoding Standard(descriptive comments, mnemonic identifiers, format, etc…)Implementation:______( 6 pts) Draws circles correctly______( 6 pts) Draws rectangles correctly__ ( 4 pts) Prompts with main loop and handles errors correctly

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 data structure html python shell graph CSE 231 Programming Project 02 Spring 2019
30 $