import turtle # create a Turtle object to access the Screen object turt = turtle.Turtle() screen = turt.getscreen() # print the height of the screen print("The height of the screen is", screen.window_height()) # close the window turtle.done()
The height of the screen is 500
import turtle # create a Turtle object to access the Screen object turt = turtle.Turtle() screen = turt.getscreen() # set the turtle to face north turt.setheading(90) # position the turtle at the bottom of the screen y_pos = -(screen.window_height()/2) turt.goto(0, y_pos) # draw a square for i in range(4): turt.forward(50) turt.right(90) # close the window turtle.done()Output: A turtle positioned at the bottom of the screen, facing north, with a square drawn. Package/library used: turtle