Python Write a program that draws a picture following a sequ
Python
Write a program that draws a picture following a sequence instructions contained in a string input by the user. Each instruction consists of at most two characters: the first character is an optional digit, called the repeater, that indicates the number of time we want to repeat the command in the second character. For example, the instruction \"3f\" means we want to do turtle.forward three times. Since the repeater is optional, the user could enter \"fff\" to achieve the same effect.
The following table shows the letters allowed in the input string, and what they mean.
The user will specify the default values for turns and movements at the beginning of the program.
Solution
a=int(input(\'number of turns:\'))
b=int(input(\'number of moves:\'))
import turtle
myimg = turtle.Turtle()
c=a+b
i=0
choice=None
tchoice=None
for i in range (c):
choice = input(\'turn or move: \')
if choice==\'turn\':
tchoice=input(\'left or right:\')
tangle=int(input(\'Angle\'))
if tchoice == \'l\':
myimg.lt(tangle)
else:
myimg.rt(tangle)
else: choice==\'move\'
mchoice=input(\'forward(f) or backword(r)\')
mdist=int(input(\'Distance\'))
if mchoice == \'f\':
myimg.fd(mdist)
else:
myimg.bk(mdist)
i=i+1
turtle.done()
