This preview shows page 1. Sign up to view the full content.
Unformatted text preview: he value used in calling myFunc!
—indented lines are executed on call
—return!y returns the value y as the results of the call!
• vectorLength(3,4)! !5.0!
• x1,!x2,!x3!=!first3Powers(6.2)! Local and global variables
• a variable defined in the Python shell is global
• you can access it and use its value in a function
• a variable assigned a value in a function definition is local;
it exists only during function execution
• declare a variable global inside a function and then you
can assign to the global variable of that name:
global!CHARS;!CHARS!=!list("abc") if6R6else blocks!
• if!condition :!!!!#!if!statement!
• elif!condition :!!#!elif!optional,!repeated!
• Python executes the first section that has a True6
condition, or else the else statement if present Strings: convert t...
View Full Document
This document was uploaded on 02/14/2014 for the course COMP 1012 at Manitoba.
- Winter '14
- Computer Science