Answer:
See Explaination
Explanation:
import turtle
def drawLine(x,y,height):
'''
method to draw a vertical line from x,y with given height
'''
turtle.up()
turtle.goto(x,y)
turtle.down()
turtle.goto(x,y-height)
def drawSet(x,y,height):
'''
method to draw a full set of tally marks
'''
temp = x
#drawing 5 vertical lines
for j in range(4):
drawLine(temp,y,height)
temp+=20
#drawing a line crossing all previous lines
turtle.up()
turtle.goto(x-5,y-height/2)
turtle.down()
turtle.goto(temp-15,y-height/4)
def drawPartialSet(x,y,height,count):
'''
method to draw an incomplete set (less than 5 tally marks)
'''
temp = x
for j in range(count):
drawLine(temp,y,height)
temp+=20
#getting number
num=int(input('Enter the number: '))
#finding number of complete sets
sets=num//5
#finding number of incomplete sets
extra=num%5
#setting up turtle
turtle.setup(width=500,height=500)
turtle.pensize(5)
turtle.speed(0) #max speed
#starting x, y coordinates
x=-240
y=250
line_height=80 #height of one tally line
#drawing all complete sets
for i in range(1,sets+1):
drawSet(x,y,line_height)
x+=line_height
if i%5==0:
#moving to next line after every 5 sets
x=-240
y-=line_height+50
#drawing extra sets if exist
if extra>0:
drawPartialSet(x,y,line_height,extra)
turtle.ht() #hide turtle
turtle.done() #finish drawing