Python Session # 4 By: Saeed Haratian Spring 2016 Outlines - - PowerPoint PPT Presentation

python
SMART_READER_LITE
LIVE PREVIEW

Python Session # 4 By: Saeed Haratian Spring 2016 Outlines - - PowerPoint PPT Presentation

Fundamentals of Programming Python Session # 4 By: Saeed Haratian Spring 2016 Outlines turtle Module The for Loop turtle methods and tricks Functions turtle Module


slide-1
SLIDE 1

ميـــحرلا نحنحنرلا للوللوا مــسب

Fundamentals of Programming

Python

Session # 4

By: Saeed Haratian Spring 2016

slide-2
SLIDE 2

Outlines

 turtle Module  The for Loop  turtle methods and tricks  Functions

slide-3
SLIDE 3

turtle Module

 Screen

 mainloop  bgcolor  title

 Turtle

 forward  left  color  pensize

slide-4
SLIDE 4

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)

slide-5
SLIDE 5

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)

slide-6
SLIDE 6

more turtle methods and tricks

 Turtle

 backward  right  penup  pendown  speed  shape  stamp

slide-7
SLIDE 7

Functions

 Syntax :

def NAME( PARAMETERS ): STATEMENTS

 Some Functions Require Parameter like abs, pow, max  Fruitful Function  Void Function

slide-8
SLIDE 8

Example : Compound Interest

slide-9
SLIDE 9

Function Variables

 create a local variable inside a function  only exists inside the function  cannot use it outside