CSE 1010 Lecture 9: Functions, User defined functions, Multiparameter functions, Named arguments, Default arguments
CSE 1010 verified notes
9/29View all
Document Summary
Functions are a way to group statements together and give them a name: after writing a function to solve a problem you can recall it in other programs so that you never have to re-solve that problem. Print, input, len, int, random. randint: you don"t need to know how they work, just what they do. Every language gives you the ability to create your own functions. Creating functions is an integral part of a well designed program. Format: name: any valid identi er, parameters: the unknowns used in the body, body: any group of statements. After a functions ends, all of its variables are cleared. If there is already a variable with the same name de ned before we call the function, it is overwritten, but once it is cleared and the variable reverts. Do not need to be in order, but the parameter names must be already de ned in the function.