Answers for "python turtle examples"

0

python turtle tutorial

>>> turtle.home()
>>> turtle.dot()
>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
>>> turtle.position()
(100.00,-0.00)
>>> turtle.heading()
0.0
Posted by: Guest on March-28-2021
5

instructions following python turtle

import turtle
import time

print("important instructions")
time.sleep(2)
print('Keys going to work')
print("/_\ Arrow Key for going up")
print("<| Arrow key for left ")
print("|> Arrow Key for right")
print("\_/ Arrow key for down")
print("C command will be used for making circles")
print("F command for cleaning all drawing you made")
print("you can click any where on screen and the painter will move to the distance you pressed on your own app")
print("W command for wrighting if you gave it A")
print("T will be used to change the thickness of your painter")
print("A command for if you want to move it another place without any lines")
print("Q command for quiting app")
print()
time.sleep(17)
print("app starting.......")
#my setup
turtle.setup(700,550)
wn = turtle.Screen() 
wn.title("Key board follower turtle") 
wn.bgcolor("yellow")
mo = turtle.Pen()
mo.left(90)
mo.shape("turtle")

#Movement Functions
def up():
    print("forward by 30")
    mo.forward(30)
 
def left():
    print("left for 45*")
    mo.left(45)
 
def right():
    print("right for 45*")
    mo.right(45)
    
def dragging(x, y):
    mo.ondrag(None)
    mo.setheading(mo.towards(x, y))
    mo.goto(x, y)
    mo.ondrag(dragging)
    print("Moved to the  distance you clicked ")

def back():
    print("backward for 30")
    mo.backward(30)

def circle():
    print("Please give me the radius of circle:-")
    r = int(input())
    mo.circle(r)

def thickness():
    print("Plese input the thickness level in int:- ")
    thick = int(input())
    mo.pensize(thick)
    
def clean_all_Drawing():
    print("Cleared your all drawing")
    #mo.left(180)
    mo.clear()
    mo.reset()
    mo.left(90)
    
def write():
    print("pen in wrighting stage")
    mo.pendown()
    
def pen_in_air():
    print("Pen in stage of not writhing")
    mo.penup()
    
def Exit():
    print("Thanks for using your own app")
    wn.bye()

#calling my functions to make turtle obeyful
wn.onkey(up, "Up")
wn.onkey(left, "Left")
wn.onkey(right, "Right")
wn.onkey(back,"Down")
wn.onkey(circle,"c")
wn.onkey(thickness,"t")
wn.onkey(clean_all_Drawing,"f")
wn.onscreenclick(dragging)
wn.onkey(write,"w")
wn.onkey(pen_in_air,"a")
wn.onkey(Exit, "q")

wn.listen()
wn.mainloop()
Posted by: Guest on June-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language