ميـــحرلا نحنحنرلا للوللوا مــسب Fundamentals of Programming Python Session # 4 By: Saeed Haratian Spring 2016
Outlines turtle Module The for Loop turtle methods and tricks Functions
turtle Module Screen mainloop bgcolor title Turtle forward left color pensize
The for Loop for i in [0,1,2,3]: alex.forward(50) alex.left(90) for i in range(4): alex.forward(50) alex.left(90)
The for Loop … for c in ["yellow", "red", "purple", "blue"]: alex.color(c) alex.forward(50) alex.left(90) clrs = ["yellow", "red", "purple", "blue"] for c in clrs: alex.color(c) alex.forward(50) alex.left(90)
more turtle methods and tricks Turtle backward right penup pendown speed shape stamp
Functions Syntax : def NAME( PARAMETERS ): STATEMENTS Some Functions Require Parameter like abs, pow, max Fruitful Function Void Function
Example : Compound Interest
Function Variables create a local variable inside a function only exists inside the function cannot use it outside
Recommend
More recommend