Today I’m giving a demo of the Thonny Python IDE (Integrated Development Environment) to my Computer Studies students. I recently learned about this editor from a post someone sent to the ACSE mail list.
Turtle Graphics Cheatsheet
Turtle Pen | |
turtle.pen(pencolor=”red”, pensize=10, fillcolor=”black”) | Pens have attributes such as color, size, and fillcolor. |
turtle.up() | Sets the pen state to be up (not drawing). |
turtle.down() | Sets the pen state to be down (drawing). |
turtle.color(r,g,b) | See below |
turtle.color(s) | Sets the color that the pen will draw until the color is changed. It takes either 1) three arguments, each a floating point number between 0.0 — 1.0, where the first the amount of red, the second is the amount of green, and the third is the amount of blue, or 2) a “color string” the name of a TK color (e.g., “black”, “red”, “blue”, …) |
turtle.begin_fill() | See below |
turtle.end_fill() | To fill a figure, use turtle.begin_fill() before you start drawing the figure. Draw the figure. Then execute turtle.end_fill(). The figure drawn between the two fill commands will be filled with the present color setting. |
turtle.hideturtle() | See below |
turtle.showturtle() | Sets the state to hide / show the turtle. When shown, you see it as a small arrowhead pointed in the direction of the heading. |
turtle.fill(True) | To fill a figure, use turtle.fill(True) before you start drawing the figure. The figure drawn will be filled with the present color setting. |
Turtle Draw | |
turtle.right(degrees) | Turns the direction that the turtle is facing right (clockwise) by the amount indicated (in degrees). |
turtle.left(degrees) | Turns the direction that the turtle is facing left (counterclockwise) by the amount indicated (in degrees). |
turtle.forward(distance) | Moves the turtle forward (in the direction the turtle is facing) the distance indicated (in pixels). Draws a line if the pen is down, not if the pen is up. |
turtle.backward(distance) | Moves the turtle backward (in the direction opposite to how the turtle is facing) the distance indicated (in pixels). Draws a line if the pen is down, not if the pen is up. |
turtle.setheading(angle) | Sets the orientation of the turtle to angle. Here are some common directions in degrees: 0 (east) 90 (north) 180 (west) 270 (south) |
turtle.goto(x,y) | Moves the turtle to the specified coordinates, drawing a straight line to the destination (x,y) if the pen is down, and not drawing if the pen is up. |
turtle.circle(radius) | Draws a circle of the indicated radius. The turtle draws the circle tangent to the direction the turtle is facing. |
Turtle other | |
turtle.xcor(),turtle.ycor() | Returns the x – coordinate / y – coordinate of the current pen position. |
x, y = turtle.pos() | Sets the variables x and y to the turtle’s current position |
turtle.exitonclick() or turtle.done() | To prevent the screen from closing. |
turtle.bye() | Close the turtle drawing window |
turtle.speed(integer) | Set the animation speed of the turtle. 1 = slowest, 10 = fastest. 0 turns off animation completely |
turtle.shape(‘turtle’) | Set the shape. You can also choose from arrow, square, circle, triangle and classic |
Compiled from: | http://bit.ly/2J8Cj77 |
http://bit.ly/2kr4tMN | |
http://bit.ly/2krp7MJ |
Drawing Grass in Pygame
As part of my Python Pygame unit I am asking students to draw a landscape. Just for fun, I thought I would ask them to create a function to draw some grass at the bottom of the screen.
Here’s the function template I gave them: Continue reading “Drawing Grass in Pygame”
Why Python Is Great – Swapping Variables
https://twitter.com/pbeens/status/996769796795654145
OSSTF 2018 Python Presentation
The Turtle Graphics cheatsheet can be accessed as a PDF or in Google Sheets.
Telephone Words Scrabble Challenge
I loved programming in Delphi many years ago and still subscribe to a “Delphi for Fun” newsletter. It was in one of these newsletters that I read about the “Telephone Words” challenge where you have to find the words in a dictionary that would correspond to the presses of the keys on a telephone. Continue reading “Telephone Words Scrabble Challenge”
Python String Assignments
View the document in a new tab here.
CS Circles Tutorials
Getting Started
- Using this website
- Console (although you are encouraged to use PyCharm instead, which is available here.)
- Visualize
- Cheatsheet
- Resources
Tools
- Portable Apps
- Chrome
- Notepad++
- Lastpass
- Diigo (social bookmarking)
- Google Drive
- Google Takeout
- Google Sites (the NEW Google Sites)
- Google Keep
- Gmail
- Dropbox
Admin
(This is a common part of the course outlines for ICS3C, ICS3U, and ICS4U )
- Earbud reminder
- Filename convention (prepend initials)
- You will be instructed when to use this.
- Administrivia
- Reminder service
- Email assignment
- Pre-course questionnaire
- Keeping Organized using Google Keep
- Intro to Computer Science
- Reminder service check
- Online Marks (except ICS4U)
- Google20 Days (except ICS4U)
- #BDSICS Tweets
- Curriculum Link (PDF)
You must be logged in to post a comment.