ITP 115 Lecture 9: ITP 115 Lecture 9

76 views4 pages

Document Summary

Print() input( ) returns a string int(string) returns an int str(int) returns a string len(sequence) returns # of items. Perform a task and return control to your program. Allow you to break up code into manageable, bite-size chunks. Programs w/functions can be easier to create and work with. Function definition: what it does, like recipe. Function call: actually using the function. Use the word def, followed by a function name (same rules as a variable name), followed by a pair of parentheses, followed by a colon, and then an indented block of statements def functionname (): statement(s) # define a function called spam def spam (): print( spam, spam, spam ) Calling a function: use the name of the function followed by a set of parentheses functionname (, must define the function before you call it print( spam, spam, spam ) # define a function called spam def spam (): spam() spam() Output spam, spam, spam spam, spam, spam.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents