Join 136,272 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,252 people online right now. Registration is fast and FREE... Join Now!
On of the most impresive learning tools I've seen in a long time is the Turtle Art program that comes with the OLPC machine. It uses interlocking code elements to show the student the basics of procedural programming.
I taught Terrapin Logo to kids grades second through fifth, many many years ago. The second graders started with squares.
well, its hard to post something overly complex considering I only have an hour per each library computer session, I will try to post something a little more "advanced" tomorrow ")
def engine(): reset() up() #the letter "E" goto(40,70) down() goto(0,70) goto(0,10) goto(40,10) up() goto(40,40) down() goto(0,40) up() #the letter "E" moved to show a motion of entire shape of (-20,-20) color("green") goto(40-20,70-20) down() goto(0-20,70-20) goto(0-20,10-20) goto(40-20,10-20) up() goto(40-20,40-20) down() goto(0-20,40-20) up() #the letter "E" moved to show a motion of entire shape of (-20,-20) color("red") goto(40-40,70-40) down() goto(0-40,70-40) goto(0-40,10-40) goto(40-40,10-40) up() goto(40-40,40-40) down() goto(0-40,40-40) up() #the letter "E" moved to show a motion of entire shape of (-20,-20) color("maroon") goto(40-60,70-60) down() goto(0-60,70-60) goto(0-60,10-60) goto(40-60,10-60) up() goto(40-60,40-60) down() goto(0-60,40-60) up() #the letter "E" moved to show a motion of entire shape of (-20,-20) color("pink") goto(40-80,70-80) down() goto(0-80,70-80) goto(0-80,10-80) goto(40-80,10-80) up() goto(40-80,40-80) down() goto(0-80,40-80)
sleep(2),
if __name__ == '__main__':
engine() sleep(3) done()
CODE
#Bicyclewheel #As the rain falls I am thankful for the cooling aire. #The heat has been steadfast and tonight it breaks! speed("fastest") x=0 y=0 up() goto(x,y-50) down() fill(1) color("black") circle(50) fill(0) up() goto(x,y-40) down() color("white") fill(1) circle(40) fill(0) color("black") up() goto(x,y) down() goto(x+40,y) goto(x,y) goto(x-40,y) goto(x,y) goto(x,y+40) goto(x,y-40) goto(x,y) setheading(45) forward(40) backward(80) goto(x,y) setheading(135) forward(40) backward(80)
up() sleep(1) reset() write("created by dave_6_10")
And this one is especially useful for the exploratory purpose of learning to use turtle graphix
speed("fastest") color("blue") down() for i in range(36): for j in range(10): forward(50) right(36) right(10) up()
Also, I'm not fond of goto. It breaks the metaphor of a turtle taking some steps, dipping it's tail in paint, picking it up and putting it down. What does a turtle know of x and y? It only need know move and turn. Here's a cube without goto, by way of example:
CODE
def DrawCube(size, zsize, boxColor, sideColor): def square(size): down() for step in range(4): forward(size) right(90) up()
Hey since your so Wizardours and full of knowledge in the python language maybe you could help me with fitting this whole character sheet into one window
DnD Charactersheet:
CODE
__author_="Dave_6_10" __title_="Dungeons and Dragons character sheet" __version_="1.0"
def page1(): print(""" ____________________________ _______________________________ Dungeons CHARACTER NAME PLAYER ==>-&----- ____________________________ ___________ ___________ _________ Dragons CLASS AND LEVEL RACE AUGMENT DEITY _______ _______ ______ _______ _______ _________ _________ _________ size age gender height weight eyes hair skin
Define window. The code you've shown merely dumps text to a screen. If it's a terminal window, define more rows. You're limited by your environment, not the language.
Design it in a word processor, dump it to a PDF. Make an image and display the image. If you want to interact with the user, then it becomes more interesting.
Personally, I'd use HTML. It's ubiquitous, understood by most users, easy to enter data into and print from.