Complete Python Turtle Graphics Overview! (From Beginner to Advanced)
Вставка
- Опубліковано 27 вер 2024
- Follow me / keithgalli for more tech content!
In this video I walk through the Turtle Graphics library of Python. This is a perfect video for people just starting out programming to visualize their work. If you have any questions about this video, leave a comment down below!
Feel free to watch on 1.25x or 1.5x speed to learn faster!
Link to Turtle Documentation:
docs.python.or...
Source Code for this video!
github.com/Kei...
First video in my Python Programming series:
• Math & Variables in Py...
I will be uploading tutorial videos weekly, so don't forget to SUBSCRIBE to not miss anything :)
-------------------------
Follow me on social media!
Instagram | / keithgalli
Twitter | / keithgalli
-------------------------
If you are curious to learn how I make my tutorials, check out this video: • How to Make a High Qua...
*I use affiliate links on the products that I recommend. I may earn a purchase commission or a referral bonus from the usage of these links.
Video Outline!
0:25 - All Examples seen in this Video
1:40 - Turtle Setup
2:48 - Basic Lines & Turns
5:22 - Creating Simple Shapes (Squares)
8:00 - Common Mistakes
8:30 - Adding color in Turtle
11:46 - Pen up, Pen Down
15:16 - Creating Complex Shapes (Flowers)
22:19 - Using Math Library in Drawings
26:41 - Recursive Stars Example
Feel free to watch on 1.25x or 1.5x to learn faster!
Thanks for watching :)
SUBSCRIBE for future tutorials like this
Can you give me the name of program?
The turtle graphics library of python. The editor I'm using to write the python code is Sublime Text 3. Does this answer your question?
This library should come default with python so if you have that, you would have the turtle library. If you want the link to the code i wrote in this video, that's in the Description of the video.
Sorry if i disturbed you but i don't need this..
you know the programe (Visual stdio , CodeBlocks..) like this .. 🙁
www.sublimetext.com/3
My man stayed up at 3am to educate us.
respect, bro.
Right?! his notifixation mad eme laugh
Timezone
"You made a square, yay!" That also was my reaction as well when I did it. Programming is awesome.
no
*python is awesome
no
Yes! Programming ia awesome 👍😎
That simple before mastering python i used to know na logo so it's very easy this just for recall
You're doing a amazing job helping beginners like me try my hands at Python and see visual, tangible results. Thanks for that!
Through this tutorial, I went from knowing nothing to being able to do fun & cool patterns. Great video. Thanks!
20:14 I just love how you're making this at 2:30AM
I make videos at 4-5AM in the morning (before sleeping) Waiting eagerly to get such appreciation for my videos :P
@@SahajOberoi nah
18:30 The turtle language has a repeat command (maybe not in python). If you use the for-loop, you should write "for _ in range(100):", because you don't need the variable (i).
for _ in range(x) uses an already declared variable _ which contains the return of an interactive python session. Using a discard as a variable is not a good approach and can lead to misinformation being outputted in python. Declaring a variable on a for loop is not that big of a deal and will not save you any time nor space. A for loop will always create a variable for an iteration. That is just logic.
Thank you for showing us what a newbie would do, then for showing us how it can be done to save time and typing, or in other words, the proper way to do the coding. You are the best teacher!
Thanks Keith, this helped me out so much. You have such a good way of explaining things without them being over complicated. In fact I think I might show this to my students when I teach it! :)
Glad you enjoyed the video and thank you for the kind words! Comments like this keep me motivated to keep making more videos :)
Thanks, man. I think you did a better job of explaining it than my instructor did.
It's 8:52pm, my intro to programming final is due soon. Thank you for this, you're a life saver
bro is a straightforward best tuitor
Bro great tutorial I am new to python but after learning the turtle I have a way better understanding of python thanks!!!!!!
Love to hear that!! You're very welcome :)
Perfect prog for diagram showed in video. Thanks for the turtorial.
import turtle
d=turtle.Turtle()
d.speed(20)
d.color("red", "yellow")
d.begin_fill()
for i in range(36):
d.forward(300)
d.left(170)
d.end_fill()
The video is exactly what I am looking for. I am new to Python. I studied math in college and graduated back in 2005. I didn't use math professionally. I was reluctant to learning Python. I took C Programming and this language seems more suited for me.
for anyone wondering for the flower, use this:
for i in range(36):
bob.forward(300)
bob.left(170)
i made a hexigon
Very nice (borat voice)
Look at the back of him "MIT"
Muzaffarpur Institute of Technology
yo thanks mate
you just helped me get a few credits for the university
may god bless you, and keep up THE GOOD WORK
thank youu ure a good teacher ! loved the way u think nd how u knew the cause of the errors especially in the last graph 😍 ..keep it up ❤
Finally I have a perfect video to send to people who ask me how to start programming. For fun.
You should include the section how to install the package lol
Thanks for the help, I was trying to graph something using turtle and this video helped a lot.
Thank you Keith, you are a wonderful instructor! Very clear and precise.
Excellent stuff! Really easy to understand without all the 'technical' jargon. I now feel like I can do this Pythonning thing, yippeeee!!!!
Hey @Keith Galli! I recently found out your channel. I'm new at python and your videos are so helpful. Thanks a lot!
I'm looking forward to more videos like this ,appreciate this videos
MSW Logo in Python
for i in range(2000000):
x.forward(math.sqrt(i)/5)
x.left(i%185.273567834657834658734876578)
@Ismail Amiri you didn't see this formula finished did ya?
Nice widening spirals, becoming a space stars image. Just a kind notice to others: if you don't know how to use turtle.Screen().update() and speed(0) - don't even think to launch anything with 2M iterations.
@Ismail Amiri yikes, wikipedia tells there's quite a story behind "watermelon stereotype". I don't get your joke anyway.
Alright guys, I made this script to help yall make squares:
def square(turt, length, doFill = False):
if doFill:
turt.begin_fill()
for i in range(4):
turt.forward(length)
turt.left(90)
turt.end_fill()
else:
for i in range(4):
turt.forward(length)
turt.left(90)
All you have to do is do square({turtle}, {length}, {fill: True/False})
For example I could do this and it makes a square with a length of 100 that fills:
bob = turtle.Turtle ()
square(bob, 100, True)
Setting the fill to "True" fills and settings it to "False" doesn't fill (CASE SENSITIVE!). Also, not setting the fill just turns it off by default.
And remember to put the def before you call the square or it won't work
@@stae24 ?
THANKS A LOT buddy.. all i needed i found in one video..thanks again
18:00 just use
for i in range(10):
keith.forward(100)
keith.left(135)
keith.forward(100)
Some script i have made:
import turtle
n = 10
d = [360/n, n]
a = turtle.Turtle()
for i in range(d[1]):
a.left(d[0])
a.forward(5)
turtle.done()
It will draw a polygon of "n" sides
N = 10 -> decagon
Noice
import turtle
a = 50
turtle.circle(a)
turtle.done()
work smarter not hard
I got this from my computer teacher to watch the first 15 minutes of this video.
im guessing you go to stratford
Shs?
Nykolous soar high school?
Nice! to draw that flower, I just typed forward(100) right(160) ahead (100)... a hundred times before remembering to use copy and paste!!! NICE VIDEO!
20:11 "you're waking up in 5 hours."
Lol yeah I made this video pretty late at night xD
flux
Not even the right timestamp you coronafuk!
so sry 4 the harsh words!! oops
Thanks! My teacher thinks Im a pro now
Try this one:
import turtle
window = turtle.Screen()
drawer = turtle.Turtle()
window.title("Drawing")
window.bgcolor("white")
counter = 110
while True:
drawer.forward(counter)
drawer.left(150)
drawer.forward(counter)
drawer.left(165)
counter = counter + (counter/(counter/3))
turtle.done()
you could do this
line = 0
bob.color("red","orange")
bob.begin_fill()
while line < 20:
bob.left
(170)
bob.forward(200)
line += 1
bob.end_fill()
thank you, i really like the video and how you explained the concepts. I found it easy to understand and most of all fun. I liked how you told us to give a try at some shapes so that we could try to figure out oursleves how it works! Great video liked and subscribed
Hey Keith it was my first time using python to create something and your tutorial just helped me a lot
Thanks for the video
Subscribed
Which idle u are using
This video helped out with my homework! Thanks!
i made this yesterday, thought i would share
import turtle as t
t.speed(0)
t.pensize(1)
x = 200 # size of circle
y = 25 # agle of separation
z = 36 # number of loops completed
for i in range(z):
t.right(y)
t.color("red")
t.circle(x)
t.rt(y)
t.color("blue")
t.circle(x)
Nice explanation
This makes a python more creative and intresting
I made a graph generator using turtle module. Thanks for the tutorial
Thank you! I have homework about drawing a triangle in Python, and the book is not helpful at all. Your video is very helpful and easy to understand
Here, a fun gift:
-=-=-=-=-=-=-=-=-=-=-
import turtle as tu
a = tu.Turtle()
a.penup()
a.goto(0, -150)
a.pendown()
a.left(90)
a.speed(0)
def drawn(l):
if l < 5:
return
else:
a.forward(l)
a.left(30)
drawn(4*l/5)
a.right(60)
drawn(4*l/5)
a.left(30)
a.backward(l)
drawn(100)
-=-=-=-=--=-=-=-=-=-=-=-
change the ''5'' in ''if l < 5'' to change how detailed you want it (the higher, the less details, the faster it is rendered) and the ''100'' in the last line to control how many times it is going to be repeated. Pretty neat.
Hope you enjoy it
@@Harmonity awww wowww It's a flower!!! :P
/Dandilion Clock!!!
this the best python turtle video i ever watched.You are the best!!!! :)
amazing helped me so much as i am a novice at python
thank you alot , this helped so much... i didnt know anything about this until now
keith i made all of them and its so cool!!!! thanks keith!
you know when getting it right to draw a simple shape for the first time it feels awesome and then you get professional at it and when someone else gets it right the first time your whats the big deal you drew a sqaure😅
Instead of writing...
import turtle
keith = turtle.Turtle()
... you can write
import turtle as keith
I think it’s going to work ;)
Pie XIII No it must be
import turtle
import turtle.Turtle() as keith
thanks for giving something to start
For i in range (2000)
turtle.left(i%180)
turtle.forward(i%180)
A variation on your code that plays around with the coloring:
import turtle
turtle.colormode(255)
turtle.speed(0)
for i in range (2000):
turtle.pencolor((i%180+50,0,0))
turtle.left(i%180)
turtle.forward(i%180)
That's quite cool. Like a virus through a microscope.
I did this for a uni assignment and called the turtle "Lord Tywin", I lost marks
The real question is do you regret doing it? If not then it was worth it
@@captainjacksparrow3221 it was very worth it 😂
eyyy thanks man :D i already learn some python so it was easy to do the "for loops " and something
thanks for the tutorial man you are best 🤞🤞🤞🤞
for i in range(8):
for i in range(8):
bob.forward(90)
bob.left(45)
bob.penup()
bob.left(135)
bob.forward(90)
bob.pendown()
Earned yourself another subsciber and like :) Keep up the great work!
Thank you!! :)
@@KeithGalli I was wondering, is it possible to make a 2 player chess game using turtle? I have a project on it and would love to know asap.
I would recommend using pygame instead. I have videos on connect 4 in pygame that would probably be helpful to watch
@@KeithGalli Thanks alot! Il do that
swear i saw bro getting hypnotized by the rythmic smooth movements of the lines going up down left up down left....up.....downn.......leeeffftt mmmmm.
Instead of doing bob = turtle.Turtle() while you import you can do import turtle as bob and then you can do bob.forward(10) or something like that this helps me simplify my code
Great tutorial, Thanks!
Awesome video man! Thanks for the information.
learned loads, thank you very much
yes
today I learned, thank you.
I finally got it and thank you so muck
Thanks this video was very helpful.
Amazing Python tutorial! My code works!
Thanks a lot for the video. Amazing Job.
now i love graphics
Thank for the tutorial!
thanks a lot bro so good please make more
hurts me when you say "yay" with that energy
i accidently made 2 arrows
thank you so much, this was helpful
Hey Keith, love your videos, I have watched your tkinter video, and it was excellent. I want to ask you a question about programming. About 100 years ago when I was a teenager, I learned a language called BASIC. I got pretty good at it. After that , life happened and almost 40 years passed. Now I am a disabled and at home. To keep me from getting too bored I decided to learn and realized that I wanted to build an app. I know pythons scalability make it perfect for what I want to do. My question is, where should I start to get my brain out of the command line programming.? I have watched a few object oriented tutorials but I am struggling with the main loop idea and assigning functions and syntax. Thank you for your time.
100 years?
Thanks! It helped me a lot. Specially for star tutorial :)
Great video, many thx!
You can't name it 'John Cena', so then we won't be able to see the output
thanks amigo, this is a wonderful set of examples, hugs
Dope Tutorial !!! .... looking forward to more
Nice video man! Really Needed this tutorial. Can classes be implemented as well?
Create a window with a fixed size = turtle.setup( width = 800, height = 800, startx = None, starty = None)
Nicely done and very helpful.
Thank You So Much Sir. Very Great and Very Beautiful Explanation Sir. Love form Pakistan ❤
love you bro thanks for the video
Your Videos Are So Helpful Sir
This is awesome and Helped me alot I appreciate it ! Thank you,,,
great work ...
keep it up
A SIMPLE JOKE: If you give turtle name "JOHN CENA" we won't be able to see the turtle graphics after running the program..."you can't see me"-JOHN CENA
but on serious note.Tthankyou sir..tutorials are fantastic
Try to run this for 10 mins:
import turtle
pointer=turtle.Turtle()
while True:
pointer.forward(200)
pointer.left(160)
pointer.forward(200)
pointer.left(1)
I did, Looks cool! :)
ah, the angle was 160 not 170 xD a small mistake can spoil whole stuff
anyways, epic video man. keep it up :)
try putting 0.1 instead of 1 it is way cooler
getting error "multiple statements found while compiling a single statement"
Just try this, it is amazing bro! Thanks
if you want to use RGB values if you type "turtle.colormode(255)"
just after you initiate your turtle object you can then pass your RGB values like (255,255,255)
he said its a lot more work its not...
t = turtle.Turtle()
turtle.colormode(255)
t.color(255,255,255)
Great video. The question is: How to have the second screen displaying the visual outcome of the code? (the Python Turtle Graphic)
same here. i wish to know too!
@@abigailc6271 i am not sure exactly what the question is but if u want to know how to get the screen where you can see the program itself drawing, u just run the program, i am not sure which ide or text editor ur using but just google "how to run a python program in (ide / text editor name) and just running it should bring up the screen
keith galli=='gally boy'
Apna tyme ayega !!!
Thanks it was great and usefull
Very good. Thanks.
i got that error:- Traceback (most recent call last):
File "C:\Users\Som3a\Desktop\jh.py", line 1, in
import turtle
File "C:\Users\Som3a\Desktop\turtle.py", line 1, in
som3a=turtle.Turtle()
NameError: name 'turtle' is not defined
Just import turtle
You need to make sure to didn't save the file as turtle.py. You've called a script turtle.py, which is shadowing the turtle module in the standard library. Rename it.
@@ramiralcantara1731 How do i rename it though??
@@ramiralcantara1731 I almost gave up on this, thanks for your insight
I love this video and on my language jag älskar den här videon
Check this code out - Pointless, long but very satisfying
import turtle
arrow = turtle.Turtle()
for i in range (1,100):
for i in range (1,2):
for i in range (1,38) :
arrow.forward(150)
arrow.left(170)
arrow.penup()
arrow.forward(150)
arrow.pendown()
turtle.done()
please add indents accordingly
Nicely done! Here's how you can make this image instant and use "Escape" button to close it:
import turtle
def game_exit():
print('Escape button pushed')
window.bye()
turtle.onkey(game_exit, "Escape") # keys: www.tcl.tk/man/tcl8.4/TkCmd/keysyms.htm
turtle.listen()
window = turtle.Screen()
window.tracer(0)
window.title("Rio Python demo animation")
window.bgcolor("#34D4FC")
arrow = turtle.Turtle()
for i in range (1,100):
for i in range (1,2):
for i in range (1,38) :
arrow.forward(150)
arrow.left(170)
arrow.penup()
arrow.forward(150)
arrow.pendown()
window.update()
turtle.done()
What a legend 👍🏾