If all thelittle snowflakes
were hershey bars and
milkshakes, oh what a snow it
would be.
I’d stand outside with
my mouth open wide,
ah ah ah ah ah ah ah ah ah ah.
So I’m acoder?
❄ Wrote my first program in 2nd grade (no, it wasn’t
Hello World)
❄ 1st computer in my house: Leading Edge with
Lotus 1-2-3 didn’t work! (It did 6 months later
after I fixed it - I was 8!)
❄ Learned and then taught SPSS while in college
❄ Started creating websites in Grad School
❄ Had to program Objective C on NeXT cubes in
Grad School
❄ Learned SQL & Databases & Query tools
❄ Started on Salesforce 10 years ago
5.
Let’s review someconcepts
Variables
How you can hold values - a field
in Salesforce is a variable
Libraries/Modules
Can be imported into some
languages that add to the
functionality available; We’ll be
using the Turtle module today
which is based on Logo (an
education programming language
created in the 1960’s)
Syntax
The rules that help make up a
programming language. Like
indenting lines that run as part of
a loop in Python or ending SQL
commands with a semi-colon.
Loops
The computer can repeat tasks
for you over and over and over
again
While - as long as something
holds true
For - a specified # of times
Python
Interpreted, Object-oriented ,
High-level programming
language; But don’t worry - it’s
easy to learn! Great for
automating tasks.
Hacking
Programming! Today you are all
hackers!
6.
Python Turtle Basics
Gettingstarted
from turtle import *
Grok doesn’t do this, but usually
in Python you have to “name”
turtle and every command begins
with that “name”
E.g. tina = turtle.Turtle()
tina.shape("turtle")
Turning
right(degrees)
left(degrees)
Remember from geometry: A
circle is 360 degrees and a
triangle has 180 degrees in the
sum of its angles.
Color
pencolor(name)
Available colors:
https:/
/wiki.tcl-lang.org/page/
Color+Names%2C+running%2C+
all+screens
Don’t include spaces in the
names!
Moving
forward(# steps)
backward(#steps)
Starting position:
setposition(x,y)
Draw vs. Not Draw
penup()
pendown()
Line thickness
pensize(#)
7.
April showers bring
Mayflowers
November colors explode to
December white snowflakes
Let’s make some snowflakes with
Turtle in Python!
8.
Place your screenshothere
Frozen
https:/
/groklearning.com/hoc/activity/snowflake/
Fractals
9.
Exercise Part 1(5 min)
❄ Moving Forward (2 min)
❄ Fair & Square (3 min)
❄ Add a chat message if
you need help!
❄ You can copy code from
the instruction slides!
10.
Exercise Part 2(5 min)
❄ First Snowflake ❄ Add a chat message if
you need help!
❄ You can copy code from
the instruction slides!
You can do this!
11.
Exercise Part 3(2 min)
❄ More like a Snowflake ❄ Copy your code from
First Snowflake and
paste it in this exercise
first!
❄ Add a chat message if
you need help!
❄ You can copy code from
the instruction slides!
12.
Exercise Part 4(5-7 min)
❄ Many-pointed
snowflake
❄ Hints: For Loop!
❄ Add a chat message if
you need help!
❄ You can copy code from
the instruction slides!
13.
Exercise Part 5(3 min)
❄ Arms need Hands
Hints:
❄ Remember forward and
backward
❄ Think about your angles
❄ Add a chat message if
you need help!
❄ You can copy code from
the instruction slides!
14.
Exercise Part 6(5-7 min)
❄ Frozen Fractals ❄ Add a chat message if
you need help!
❄ You can copy code from
the instruction slides!
Want Moar?
❄ Createthe Extension Snowflakes found at the end
of this Hour of Code (presented on slides 19-26 as
Challenges with answers hidden)
❄ Do another hour of code lesson
❄ Take advantage of other free learning resources
(see next slide)
Oh! What a snow it will be!
Moar Fractals
Snowflakes areonly one
thing in nature that has
a fractal pattern. The
photos to the right
come from a display on
patterns in nature at
the Museum of Science
and Industry in Chicago.
Can you think of other
places in nature you see
fractals?
19.
Challenge 1 Codeanswer is “hidden” below (or revealed in
next slide)
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(6):
for j in range(4):
pencolor('skyblue')
forward(25)
right(45)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
backward(50)
right(45)
pencolor('skyblue')
backward(100)
right(60)
20.
Challenge 1 Codeanswer is below
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(6):
for j in range(4):
pencolor('skyblue')
forward(25)
right(45)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
backward(50)
right(45)
pencolor('skyblue')
backward(100)
right(60)
21.
Challenge 2 Codeanswer is “hidden” below (or revealed in
next slide)
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(6):
pencolor('skyblue')
forward(50)
right(45)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
backward(50)
right(45)
pencolor('skyblue')
forward(50)
right(45)
pencolor('cornflowerblue')
forward(50)
right(45)
forward(25)
backward(25)
left(90)
forward(25)
backward(25)
right(45)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
right(45)
forward(25)
backward(25)
left(90)
forward(25)
backward(25)
right(45)
backward(50)
right(45)
pencolor('skyblue')
backward(100)
right(60)
Challenge 3 Codeanswer is “hidden” below (or revealed in
next slide)
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(12):
for j in range(2):
pencolor('skyblue')
forward(50)
right(60)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(120)
pencolor('mediumblue')
forward(50)
backward(50)
right(60)
pencolor('skyblue')
backward(100)
right(30)
24.
Challenge 3 Codeanswer is below
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(12):
for j in range(2):
pencolor('skyblue')
forward(50)
right(60)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(120)
pencolor('mediumblue')
forward(50)
backward(50)
right(60)
pencolor('skyblue')
backward(100)
right(30)
25.
Challenge 4 Codeanswer is “hidden” below (or revealed in
next slide)
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(12):
for j in range(3):
pencolor('skyblue')
forward(25)
right(45)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
backward(50)
right(45)
pencolor('skyblue')
forward(25)
right(45)
pencolor('cornflowerblue')
forward(50)
right(45)
forward(25)
backward(25)
left(90)
forward(25)
backward(25)
right(45)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
right(45)
forward(25)
backward(25)
left(90)
forward(25)
backward(25)
right(45)
backward(50)
right(45)
pencolor('skyblue')
backward(100)
right(30)
26.
Challenge 4 Codeanswer is below
from turtle import *
pensize(5)
pencolor('skyblue')
for i in range(12):
for j in range(3):
pencolor('skyblue')
forward(25)
right(45)
pencolor('cornflowerblue')
forward(50)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
backward(50)
right(45)
pencolor('skyblue')
forward(25)
right(45)
pencolor('cornflowerblue')
forward(50)
right(45)
forward(25)
backward(25)
left(90)
forward(25)
backward(25)
right(45)
backward(50)
left(90)
pencolor('mediumblue')
forward(50)
right(45)
forward(25)
backward(25)
left(90)
forward(25)
backward(25)
right(45)
backward(50)
right(45)
pencolor('skyblue')
backward(100)
right(30)