The code is as Follows:
Importturtleheights= [856, 420,360,260,205]defmain (): T=Turtle. Turtle () T.hideturtle ( ) forIinchRange (5): drawfilledrectangle (t,-200+ (76*i), 0,76,heights[i]/4,"Black","light Blue") DisplayText (t)defDrawfilledrectangle (t,x,y,w,h,colorp="Black", colorf=" white"): t.pencolor (colorp) t.fillcolor (colorF) t.up () t.goto (x, y) t.down () t.begin_fill () t.goto (x+w,y) T.goto (x+w,y+h) t.goto (x, y+h) t.goto (x, y) t.end_fill ()defDisplayText (t): Languages= ["HAHA1","HAHA2","HAHA3","HAHA4","HAHA5"] T.pencolor ("Blue") t.up () forIinchRange (5): T.goto ((-162+76*i), HEIGHTS[I]/4) t.write (str (heights[i]), align="Center", Font= ("Arial", 10,"Normal")) T.goto (-162+76*i), 10) T.write (languages[i],align="Center", Font= ("Arial", 10,"Normal")) T.goto (-200,-25) T.write ("haha statistical Chart", Font= ("Arial", 10,"Normal")) T.goto (-200,-45) T.write ('( ha ha ha haha ah haha)', Font= ("Arial", 10,"Normal") ) Main ()
The effect is as Follows:
Use Python's Turtle module to draw a simple bar chart