Looking for help with my code for my Python class. My code works perfectly, but
ID: 3808109 • Letter: L
Question
Looking for help with my code for my Python class. My code works perfectly, but I am stuck trying to figure out a final print statement that will, on the turtle graphic screen (if possible), print i.e "Red Turtle Wins!" My code is below, thanks in advance! Hopefully you can make out the last line.
from turtle import from random import randint speed C10) penupC) gotoC-140, 140) for step in range (16) write step, align z center right 90) forward C10) pen down C) forward C150) penupC) backward 160) left(90) forward C20) red Turtle red color red red shapeC' turtle red. penupC) red gotoC-160,100) red.pendownC) blue Turtle() blue color blue blue shape C' turtle blue penupC) blue goto C-160,70) blue pendown C) purple Turtle() purple. Color C purple purple shape C turtle purple. penupO purple gotoC-160,40) purple pendownC) green Turtlec green color green green. shape turtle green. penupC) green.gotoC-160, 10D green. pendownO for turn in range (100) red forwardCrandint C1, 5)) blue forwardCrandint 1,5D) purple forwardCrandintC1,5 green forward Cran dint 1 5)Explanation / Answer
you mentioned all your code done except that writing some string on turtle screen.
so,using below command we can write the string on turtle screen with your interested font type as well as font size.
turtle.write(arg, move=False, align="left", font=("Arial", 8, "normal"))
here arg moves your argument.here in our case it is "Red Turtle Wins!".you can stored in variable and pass it as argument.
align ---alignment that means whatever string you are going to write on turtle screen where you wan to put that string.
next one is for font size,font family all these things.
turtle.write("Red turtle wins!", move=False, align="center", font=("Times NewRoman", 8, "normal"))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.