# Pages CS 151 Computational Thinking Fall 2012 Ibrahim Riaz CS 151

Go to start of metadata

# Abstract:

Project 1 attempts to use functions and simple knowledge of turtle commands to construct shapes in a low risk environment. A lot of focus is on understanding how to achieve more with little code. In that sense, the project required more thinking and less coding. The project starts by creation of simple shapes and tests the users design ability by asking us to combine the shapes and then demonstrate applications of functions by introducing the idea of parameters. Parameters allow us to change input values and affect certain variables like size or distance between two graphics. Lastly by letting us do extensions, the project lets us discover something interesting that we may not have thought about like colors or the idea of nesting functions and recalling certain functions in combinations or randomization. Although it took me a few hours in the lab and TA help, I am happy with how my first project turned out.

Do this per task

I used basic turtle commands to create a simple shape as shown above. A combination of forward and left and right helped me create this.

Similar to Image 1, I created a second image, image 2.

Using code from task 1 and 2 and then calling them within a function with parameters, I achieved the following.

1.) Created a new which combines shape 1 and 2.

2. Allow the user the ability to influence size of said shape and distance between these shapes using parameters.

3. Call combined shape with different sizes multiple times within one function.

Extensions

For my first extension, I used commands to create a function which creates an asymmetric shape using the combination shape. Moreover, I give the user to create this shape at their desired size through the use of parameters.

For my second instruction, I employ the idea of calling functions within functions and take parameters to the next level with randomization. My code creates four different symmetric shapes with a random magnitude and with random starting points between 0, 200 for x and y coordinates in 4 different colors.

For my last extension, I just called all the functions to create a new graphic for a t shirt I want to make and that was pretty cool to see.

Questions I was asked:

1. A variable is a form of storage and a parameter. A variable lets us use interchangeable values within functions.

2.A function is a set of instructions the computer can understand. They are the implementation of algorithms and help the computer execute a task.

3. A parameter is a variable that can be changed therefore allowing a user greater control over the output and the ability to recall function with a different value(parameter) as opposed to write a separate hardcode.

4. Functions save code because we can write a set of functions and call them multiple times as opposed to writing a new code to execute a task. For example if I want to have 5 boxes on screen, I call a function to create a box 5 times. If I use parameters, I can change size too just by changing one input/parameter, this prevents me writing 5 different codes for 5 boxes.

5. I like drawing 11. I do not think I can make it because I am not good enough at CS.

Conclusion

This project taught me a lot about turtle. Apart from basic graphic creation, it dug into the important concepts of variables, functions, parameters and the need to optimize processes by recalling code. I think this project gave me a wonderful understanding and foundation of coding using python and gave me the basic skills to recreate shapes in an engaging way while clarifying the purpose of parameters and their importance in coding projects. In order to complete my project I had to learn the syntax of functions and how to call them again and again. I had to learn about the random package and just the time management that I somewhat ack.

Labels
• No labels