🎨 Planning a Picture

PLTW Computer Science Principles • Unit 1 • Activity 1.1.2 • Mr. Babb

Learn

Making a program interactive

Until now your turtle programs have done exactly the same thing every single time you ran them. That changes today.

An algorithm can be designed to accept information, called input. The program processes that input and produces output — the result. Giving the user choices is what makes a program feel personal instead of canned.

# This program takes input and produces output user_name = input("What is your name? ") print("Hello " + user_name)

The = is the assignment operator. The expression on the right is evaluated, and the result is stored in the variable on the left. It does not mean "equals" the way it does in math.

Try it

💻 Run the program

Type an answer in the terminal below and press Run, exactly like the Python terminal in the code editor.

What is your name?
(output appears here)

🧠 Quick check

In the statement user_name = input("What is your name? "), what actually ends up stored in user_name?

Expect an error

The trap in every input program

This program is supposed to estimate the year you were born. Read it, then run it.

# Estimate the user's birth year age = input("How old are you? ") curr_year = 2026 birth_year = curr_year - age print("You were born around " + str(birth_year))
(click Run)
Sort it out

String or Integer?

0 / 6 sorted

Click a statement, then click the data type it gives the variable x.

string

integer

Explore

The circle method does more than circles

circle(r, e, s) takes up to three parameters:

  • r — the radius. Required.
  • e — the extent: how many degrees of the circle to draw. 180 gives a semicircle. Leave it out and you get the whole circle.
  • s — the steps: how many straight segments to draw it with. 5 steps makes a pentagon.

Move the sliders and watch what happens. The code updates as you go.

The turtle starts at the green dot facing east.

Challenge

Four shapes to make

0 / 4 solved

Set the sliders above so the drawing matches each target, then click Check. Radius is up to you.

Order matters

Filling a shape with color

Three methods work together, and they only work in one order:

  • .fillcolor(c) — names the color to fill with. Must come first.
  • .begin_fill() — marks where the shape starts.
  • .end_fill() — marks where it ends, and fills it in.

Click the four statements in the order that draws a filled circle.

Available statements:

Your program:

Predict

✏️ Pen up, pen down

You want to draw two separate circles with a gap between them. Which program does it?

Explore

Anatomy of an object command

0 / 4 found

Everything you have typed all year has this same shape. Click each colored piece to find out what it is — find all 4.

Class vs object

📄 The blueprint and the thing

A class is a design — a blueprint or a recipe. An object is one actual thing built from that design, called an instance.

# Turtle is the CLASS — the blueprint # painter is the OBJECT — one turtle built from it painter = trtl.Turtle() artist = trtl.Turtle() # a second object from the same class

Objects have properties (characteristics — what it is) and methods (actions — what it does).

Sort these: property or method?

0 / 6 sorted

property

method

It's your turn

🎨 Plan your picture

Design a picture you would like to draw with Python turtle — something that would brighten someone's day. Sketch it in your notebook first, then plan it here before you write any code.

Exit ticket

Show what you know

Answer all 8 questions, then click Grade my exit ticket. One retry allowed.

📝 Computer Science Notebook

  • Input is information given to a program; output is the result it produces.
  • The assignment operator = stores the value of the expression on the right into the variable on the left. College Board writes it a ← expression.
  • input() always returns a string, even if the user types a number. Use int() to convert it before doing math.
  • A substring is a part of an existing string.
  • Comments start with #. They are not executed — they make code readable for the next person.
  • circle(r, e, s): radius, extent in degrees, and number of steps. Steps turn a circle into a polygon.
  • fillcolor(c) then begin_fill() … shape … end_fill().
  • A class is the blueprint; an object is an instance built from it. Properties are characteristics, methods are actions.

🤔 Conclusion questions

  1. What is the difference between the input and the output of a program, and how can one affect the other? Give an example using Python code.
  2. Is there only one way to solve a problem? Explain and give an example using Python turtle.