CSC108H1 Lecture Notes - Lecture 4: Call Stack

89 views2 pages
10 Apr 2016
School
Course
yifanyang and 39659 others unlocked
CSC108H1 Full Course Notes
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.

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