Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
September 14th, 2013, 04:44 PM
 Devin79
Registered User

Join Date: Sep 2013
Posts: 4
Time spent in forums: 38 m 14 sec
Reputation Power: 0
Help with new school assignment (Part 1 of the lindemayer system)

So we are doing fractals, but we are only doing part 1. Let me post my assignment and then see if anyone can get me started on it.

assignment:

This Lab is Part 1 of building a type of fractal called a Lindenmayer system.
In this first part, you will just be implementing symple set of draw commands.

Write a program that takes 3 inputs:
1) Draw String: This must be a string of draw commands (see the table below).
2) Length: This must be an integer equal greater than 0 and less than or equal to 100. It defines the length variable used in some of the draw commands.
3) Angle: This must be a floating point number equal greater than 0.0 and less than or equal to 360.0. It defines the angle variable used in some of the draw commands.

Character Draw Commands
h
Draw a straight line segment length pixels long in the current heading.
f
Same as h
g
Move, without drawing, a straight line segment length pixels long in the current heading.
+
Turn the heading clockwise by angle.
-
Turn the heading counter-clockwise by angle.
A
Each of these color commands must change the turtle color to color that is different form the background and different from the other 5 color commands. Pick colors that you think look good together.
B
C
D
E
F
any other character
Ignore
(end)

Ok, I have been reading my textbook, but it unfortunately doesn't really tell you how to actually do this assignment. Could someone maybe give me some help one how to code this stuff, I am really lost on this one, and could really use the help.

PS. Here is one last thing our professor mentions in the assignment:

Now that you have the "if" statement at your command, you do need to check for for bad input. If the user inputs bad data, print an error message and exit the program.

#2
September 14th, 2013, 11:34 PM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,170
Time spent in forums: 1 Month 3 Weeks 2 Days 10 h 27 m 9 sec
Reputation Power: 455
__________________
[code]Code tags[/code] are essential for python code!

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Help with new school assignment (Part 1 of the lindemayer system)