This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 11/22/2009 1 ECS 10 11/23 Announcements Â¡ Last project due THURS Dec. 3. Â¡ Make some progress on it this week. Â¡ No lecture Wds! Little review project in lab hours, 11-1 in 2020 SLB. Â¡ Today â€“ adding and controlling complexity with functions. Last time Â¡ Functions in a module Â¡ Function definition Â¡ Arguments and parameters Â¡ Return values Â¡ Functions in a program Functions in Programs Â¡ Put function definitions at the top of the file, right after the imports. Â¡ Functions must be defined before they can be used! Â¡ The code in a function is not run until the function is called. Â¡ This is true whether the function is in a separate module or in the file with the program. Example def addOne(x): x = x+1 return x age = 5 next = add_one(age) print "I am",age,"and soon I will be",next Local variables Â¡ The variables inside a function are invisible to the main program. Â¡ Variables created inside a function are called local variables....
View Full Document
This note was uploaded on 01/14/2010 for the course ECS 10 taught by Professor Amenta during the Spring '07 term at UC Davis.
- Spring '07