CGSC 1005 Lecture 17: COMP SCI Nov. 21

68 views2 pages

Document Summary

Functions cont. val points to 10 initially in the function, as soon as /val = 9/, val = 9 in the function body and val = 10 elsewhere. My_print is called val = abc , count = 1. My_print is called val = 99, count = 2. My_print is called val = [1, 3], count = 3. Put functions at the top of the code. Trace code starting after the functions and point back to the functions in code tracing. For ele in range(3) 0, 1, 2. Suppose we change a parameter (str, int, list, etc. ) inside a function by assigning a new value to i. The only way for the main program to know about the change is via: a return of that parameter from the function, an assignment of the returned value to a variable in the main program. Note: this function will change the main list because lists are mutable even though there is no return function.

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

Related Questions