lec-11-30

lec-11-30 - 11/29/2009 Announcements Last project due THURS...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
11/29/2009 1 ECS 10 11/30 Announcements ± Last project due THURS Dec. 3. ± Use functions to draw some graphics. ± Change snowflake code, draw more of them. ± Then add your own picture, also using a function to draw. Last time ± Variables created inside a function are called its local variables. ± Local variables are invisible outside the function. ± Variables defined outside a function (the usual kind) are global variables. ± A function can see the value of a global variable. ± A function cannot change the value of a global variable….unless…. . One-way glass. Function can see program, program can’t see function. Function in an observation room. Example ± Let’s look at the usual rules in action again. Two variables with same name ± Python will let you write a program with a local variable named x and also a global variable named x. def addTwo(x): x = x+2 return x x = 10 z = addTwo(x) A perfectly legal Python program, but a very bad idea!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
11/29/2009 2 Usually avoid this
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

lec-11-30 - 11/29/2009 Announcements Last project due THURS...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online