In this tutorial covers four methods of importing the Turtle graphics module in Python, including using aliases and importing specific classes.
Also explains when to use each method and notes that Turtle is part of the standard Python library, requiring no separate installation.
-----------------
Method 1 : import turtle
Import turtle
Micky = turtle. Turtle ()
Creating a new turtle like this
This loads the entire turtle module, which includes :
Turtle Class
Screen Class
Drawing functions
Check the practical example for Method 1 ( import turtle )
-----------------
Method 2 : from turtle import *
from ( Keyword ),turtle ( Module Name ), import (Keyword), * ( Everything )
Check the practical example for Method 2 ( from turtle import * )
This Imports all the functions directly.
No need to use turtle ( prefix )
Not recommended for large projects.
-----------------
Method 3 : Aliasing Modules
import (Keyword), turtle (Module Name), as (Keyword), Alias name ( t )
This imports the module and give it an alias t.
Makes code cleaner & shorter
Recommended when using the module extensively.
Check the practical example for Method 3 ( Aliasing Modules )
-----------------
Method 4 : Importing classes from module
from (Keyword), turtle (Module Name), import(Keyword), Turtle (Class), Screen (Class)
Micky = Turtle ()
Screen= Screen ()
micky.forward (100) #Move 100 steps forward
micky.left (90) #Move 90 steps forward
Check the practical example for Method 4 ( Importing classes from module )
-----------------
Is Installation required ?
No, turtle is a part of python Standard Library.
You do not need to install it separately if you have standard Python installed.
Some online IDEs do not support turtles, since it requires GUI.
So run you code using editors like:
IDLE
VS Code
PyCharm
#crackitwithanu #aliasinpython #turtlegraphics #pythonmodules #aliasinpython #importinpython #pythonstandardlibrary #programmingtutorial #vscode #pycharm #idlepython #pythontutorial #learntocode #pythonbeginner #pythonprogramming