turtle.Screen().bgcolor() function in Python Last Updated : 19 Mar, 2025 Comments Improve Suggest changes Like Article Like Report The Python turtle module simplifies graphics creation, making it easier to learn programming through visualization. Built on Tkinter, it supports both object-oriented and procedural approaches. The turtle.Screen().bgcolor() method sets or retrieves the background color using color names (e.g., "blue") or RGB tuples (e.g., (255, 0, 0)).Example: Setting Background Color with a Color Name Python # importing package import turtle # set the background color # of the turtle screen turtle.Screen().bgcolor("orange") # move turtle turtle.forward(100) Outputturtle.Screen().bgcolor()Explanation: In this example, we set the background color of the Turtle screen to "orange" and then move the turtle forward by 100 units.Syntax of turtle.Screen().bgcolor() turtle.bgcolor(*args)Parameters:Format Argument Description bgcolor("color")colorA string representing the color name (e.g.,"yellow","green","blue")bgcolor(r, g, b)r, g, bInteger values(0-255) representing the RGB color codeExamples of using bgcolor()Below is the implementation of the above method with some examples.Example 1: Setting Background Color Using RGB Values Python # importing package import turtle # set the background color # of the turtle screen turtle.Screen().bgcolor(0,0,255) # move turtle turtle.forward(100) Outputturle.Screen().bgcolor()Explanation: This example sets the background color using an RGB tuple. The values (0, 0, 255) represent the blue color.Example 2: Changing Background Color Dynamically Python import turtle import time # get the screen turtle_screen = turtle.Screen() # List of colors to switch between colors = ["red", "green", "blue", "yellow", "purple"] for color in colors: turtle_screen.bgcolor(color) time.sleep(1) # wait for 1 second before changing color # move turtle forward turtle.forward(100) OutputbgcolorExplanation: The screen background color changes dynamically every second through a loop. The turtle moves forward at the end.Example 5: Using a Gradient Effect (Simulation) Python import turtle # get the screen turtle_screen = turtle.Screen() # Define a list of colors representing a gradient gradient_colors = ["#FF0000", "#FF4000", "#FF8000", "#FFBF00", "#FFFF00"] # Loop through colors turtle_screen.bgcolor(gradient_colors[0]) for color in gradient_colors: turtle_screen.bgcolor(color) turtle_screen.update() # move turtle forward turtle.forward(100) OutputbgcolorExplanation: This simulates a gradient effect by changing the background color sequentially. The turtle moves forward at the end. Comment More infoAdvertise with us Next Article turtle.Screen().bgcolor() function in Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads turtle.screensize() function in Python The turtle.screensize() function in Python's turtle module is used to set or retrieve the size of the drawing canvas (the area where the turtle moves and draws). This function helps in customizing the workspace according to user requirements.Example: Checking default screen sizePythonimport turtle # 2 min read turtle.colormode() 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.colormode() This function is used to return the color mode or set it to 1.0 1 min read turtle.fillcolor() 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.fillcolor() This method is used to return or set the fillcolor. If turtlesha 2 min read turtle.resetscreen() 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.resetscreen() This function is used to reset all Turtles on the Screen to th 1 min read turtle.bgpic() 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.bgpic() This function is used to set a background image or return name of th 1 min read turtle.Screen().turtles() 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.Screen().turtles() This function is used to return the list of turtles on th 1 min read turtle.dot() 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.dot()This function is used to draw a circular dot with a particular size, wi 2 min read turtle.tracer() 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.tracer() This function is used to turn turtle animation on or off and set a 1 min read turtle.begin_fill() 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.begin_fill() This method is used to call just before drawing a shape to be f 1 min read Like