Hardware Reference
In-Depth Information
Using User Input to Determine the
Number of Sides
It is always more fun to allow a user to interact with a program you have created. In
your turtle script, you can ask a user to set the value for the number of sides a shape in
the spiral can have.
1. Add the sensing block ask What's your name? And wait underneath the
start point blocks and before the set variable blocks.
2. Change the question to “How many sides would you like your shape to have?”
3. Add the sensing block answer to the set Number_Sides block, where you
normally type the value. Your script should look like the one shown in Figure 4-8.
4. Now run your script. It will ask the user how many sides she wants before it
draws the spiral.
FIGURE 4-8 Adding user input to a turtle spiral script in Scratch
Python Turtle Graphics
his section gives you a quick taste of the Python programming language. Python
includes a turtle module that you can use to create shapes and spirals in a similar
Search WWH ::




Custom Search