hi and welcome to the punnett square
generator hour of code by the end of
this hour of code you'll create a
program that will solve the allele pairs
based on user input in order to create
this we're going to use a graphical
version of Python called turtle graphics
let's get started by meeting the turtle
we're going to be programming with
throughout this project we're going to
be writing Python code with this turtle
named Tracy Tracy lives in a 400 by 400
pixel grid world the center of her world
is at position 0 0 let's see how we can
communicate with her if we wanted to
tell Tracy to move to another location
in her world such as the position 100
100 we would need to use the language
she understands which is called Python
if we try to communicate with her using
any other language she won't understand
what we're telling her to do so if I
wanted to move Tracy to position 100 100
and I said move to the top-right corner
she wouldn't understand what I was
saying because she doesn't understand
English
she only understands Python so instead
we need to use the command she knows if
instead I wrote set position 100 100
Tracy would understand this python
command and would then move to the
position I noted to use the set position
command we write this phrase all as one
word in lowercase letters and inside
parentheses we put the x and y
coordinates for the new position when
this command is called Tracy will move
there if we want Tracy to move to that
location without leaving a trail we can
call the pen up command before the set
position command you won't need to
remember this command when writing our
program but you will see it in the code
so now you know what it does if we've
moved Tracy to a certain position and
now want to add text to the screen at
that location we can use the write text
function to use this command we type
write text all in lowercase letters with
an underscore in between the words
inside parentheses we then write the
text we want to print inside quotation
marks so here we want to write the
number sign and then the number one
we type a comma and then inside another
set of quotation marks we write a color
name here we're using blue when we run
this code Tracy will move to position
100 100 and then print number 1 in blue
at that location for our program we're
going to start with the layout of our
punnett square already created we're
going to want to label the top and the
left hand side of each box with the
given allele value for now let's just
label each position with a number 1
through number 4 this is our code editor
you're going to be using it to write all
of your programs for this hour of code
so let me give you a quick tour on the
left side of the screen you see this
large white space right now we have all
of the commands needed to create the
base of our punnett square program you
write your code in here and when you
click the run code button all of the
commands you have typed will run and the
output will be shown in this box here
okay let's write some code at the end of
my commands if I write set position
negative 50 110 and run this code Tracy
will move to that position after running
the other commands if I then write write
text number 1 and blue Tracy will move
to that position and then type number 1
awesome I can then copy and paste this
code to write my number 2 in blue and I
would like that to be at position 50 110
let's see how that looks awesome before
you start writing commands yourself I
want to remind you that the computer is
very picky about the way commands are
written or the syntax of your code if
you misspell one word capitalized the
wrong letter or forget a set of
quotation marks the computer will
respond with an error so we need to pay
careful attention to how we're writing
our commands now it's your turn use the
example we
to add to more position labels to our
screen