+1 678 648 4277 

Turtle Graphics using Python Assignment Solution


Python Program with function and arguments

Q: Make a program in Python that displays HELLO using turtle graphics?

Solution:

import turtle def drawH(): draw.left(90) draw.forward(70) draw.penup() draw.goto(0, 35) draw.pendown() draw.right(90) draw.forward(30) draw.penup() draw.goto(30, 70) draw.pendown() draw.right(90) draw.forward(70) def drawE(): draw.penup() draw.goto(40, 0) draw.pendown() draw.right(180) draw.forward(70) draw.right(90) draw.forward(35) draw.penup() draw.goto(40, 35) draw.pendown() draw.forward(35) draw.penup() draw.goto(40, 0) draw.pendown() draw.forward(35) def drawL(cnt): draw.penup() if cnt==1: draw.goto(90, 140) else: draw.goto(170, 140) draw.pendown() draw.right(90) draw.forward(140) draw.left(90) draw.forward(70) def drawO(): draw.penup() draw.goto(280, 70) draw.pendown() for i in range(25): draw.right(15) draw.forward(10) if __name__ == "__main__": #set screen frame = turtle.Screen().bgcolor("White") draw = turtle.Turtle() #set width and speed of the pen draw.width(3) draw.speed(1) #start drawing HELLO drawH() drawE() drawL(1) drawL(2) drawO()