Whew. Experimenting with the angles requires you to change three differentplaces (numbers) in the code each time. Imagine you’d want to experiment withall of the squares’ sizes, or with with rectangles! Fortunately there areeasier ways to do so than changing lots of numbers every time.
This is wherevariables come into play: You can tell Python that from now on,whenever you refer to a variable, you actually mean something else. That conceptmight be familiar from symbolic maths, where you would write:Let x be 5.Thenx * 2 will obviously be10.
In Python syntax, that very statement translates to:
x=5
After that statement, if you doprint(x), it will actually output its value— 5. Well, can use that for your turtle too:
turtle.forward(x)
Variables can store all sorts of things, not just numbers. A typicalother thing you want to have stored often is astring - a piece of text.Strings are indicated with a starting and ending" (double quote).You’ll learn about this and other types of data you can store, andwhat you can do with them later on.
You can even use a variable to refer to the turtle by a name:
timmy=turtle
Now every time you typetimmy python knows you meanturtle. You canstill continue to useturtle as well:
timmy.forward(50)timmy.left(90)turtle.forward(50)
If we make a variable calledtilt (we could assign it a number of degrees),how could we use that to experiment much faster with our tilted squares program?
tilt=20turtle.left(tilt)turtle.forward(50)turtle.left(90)turtle.forward(50)turtle.left(90)turtle.forward(50)turtle.left(90)turtle.forward(50)turtle.left(90)turtle.left(tilt)
... and so on!
Can you apply that principle to thesize of the squares, too?
Draw a house.

Hint
You can calculate the length of the diagonal line with the Pythagoreantheorem. That value is a good candidate to store in a variable.To calculate the square root of a number in Python, you’ll need to importthemath module and use themath.sqrt() function.Exponentiating a number is done with the** operator(so squaring means**2):
importmathc=math.sqrt(a**2+b**2)