turtle.window_width() function in Python
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
turtle.window_width()
This function is used to return the width of the turtle window. It doesn’t require any argument.
Syntax :
turtle.window_width()
Below is the implementation of the above method with an example :
Python3
# import packageimport turtle # get turtle window widthprint(turtle.window_width()) # make screen object# then set size and colorsc = turtle.Screen()sc.setup(300,300)sc.bgcolor("green") # get turtle window widthprint(turtle.window_width()) # loops for pass timefor i in range(5000): for j in range(5000): pass # set size and color againsc.setup(500,400)sc.bgcolor("red") # get turtle window widthprint(turtle.window_width()) |
Output :

768 300 500
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.


