# Pages Hyeon-Seung Yu’s Home Hyeon-Seung (Alex) Yu's CS 151 Hyeon-Seung Yu's CS 151 Project 1: What is a Shape?

You are viewing an old version of this page. View the current version.

Version 7

The purpose of this project was to learn how to use the 'turtle' feature of python programming language.  As the name of the project suggests, the python turtle allows me to draw different shapes and create further complex shapes using different features.  Descriptions and images below will illustrate how my shapes became more sophisticated as I moved on to different steps and extensions in the project.

Required Codes:

• shapesA.py draws a simple chair by moving the "turtle" to left and right at different distances and different angles.  The snippet below shows some comands.

• The image below is how shapeA looks like.

• shapeB.py draws a cross by moving the turtle left and right at different distances and angles.  Basically both shape A and B are quite simple.  Below is the image of shape B.

• In shapes.py, my codes and shapes start to become more complicated.  First of all, I created multiple functions that define shapeA and shapeB so that I would not have to rewrite all the codes of shape A&B every time I want to draw them.  The define function looks like below.

• In shapes.py I also created a function that draws both shape A&B but there is a small movement of turtle between drawing those two shapes.  I intentionally put some commands between shape A&B so that they would look awkward when drawn together.  ShapeC looks like below.

• Another function shapeD draws shapeB but with a parameter.  what this means is that I can now draw shapeB with different length of sides whenever I change the number inside the funcion parenthesis.  If you can notice, I wrote 'distance' next to the function.

• Now another shapeE draws shapeD four times at different locations.  Similar with shapeD, shapeE will draw the shape of cross with the different length of sides due to the function parameter.  It looks like the below image.

• extension1.py: I completed writing this code after finishing all other extensions; therefore, I am quite familiar using loop and range function.  I decided to use those functions for this extension and wanted to draw polygons that would become bigger and increase the number of sides gradually.  So I made the straight lines to bend at different angles to form triangle, square, pentagon, and hexagon.  As the image below would show, the area of the shapes will increase as the shape turns into the next one because of the loop and range function.  There are two more things to note about this shape: 1) Before the turtle draws the next polygon, it comes back to the orignial position because of the command ht().  I used this command so that the polygons would overlap with each other.  2) I set the background and pen's color as black and white so that the distinction between the polygons can become clearer.  The shape looks like below.

• extension2.py:
Labels
• No labels