CSC108H1 Lecture Notes - Lecture 4: Call Stack
yifanyang and 39659 others unlocked
21
CSC108H1 Full Course Notes
Verified Note
21 documents
Document Summary
Method: a function inside an object [for help(str. ____) For: for variable in str: body: e. g. for char in s: [char refers to character] print (char) [will print all characters of s, if print(char) is mentioned twice, each character is printed twice e. g. hhii. Variable ch will refer to characters in string. One character at a time, from left to right. Write a function that returns the number of vowels in a given string: def count_vowels(s): Return the number of vowels in s, not including y. 0 num_vowels = 0 for char in s: if char in aieouaieou": num_vowels = num_vowels + 1 return num_vowels. Call stack: the stack of frames for functions currently being executed. When a function exits, the frame for the function is erased, and control passes it back to the statement containing the function call. The value of the function call is whatever was returned by the function.