Let the method screen.exitonclick() be the last statement in your code without indenting it.
You use this method when your using a Python IDE such as Pycharm, Spyder etc.
I don't know if you have heard of the method screen.mainloop()
This method enables you see the output of your code when you run it in a Python IDE.
Without this method, your output would appear in a flash.
I rewrote your code and here's mine
from turtle import Turtle
t=Turtle()
def square():
t.up()
t.setpos(-50,-50)
t.down()
for i in range(4):
t.forward(100)
t.right(90)
def triangle():
t.up()
t.setpos(50,50)
t.down()
for i in range(3):
t.forward(100)
t.right(120)
def star():
t.up()
t.setpos(-200,100)
t.down()
for i in range(5):
t.forward(150)
t.right(144)
square()
triangle()
star()
t.screen.exitonclick()
You can also check this excellent guide in Python turtle