Python (v3) Stack Frame Examples - Swarthmore College
Python (v3) Stack Frame Examples
CS21 at Swarthmore College
Basic Example
1
2
3
4
def f(x,y):
x = x + y
print(x)
return x
5
6
7
8
9
def main():
n = 4
out = f(n,2)
print(out)
10
11
main()
At the beginning of the program, main is called. We create
a new stack frame. Since main has no parameters, the stack
frame is empty.
2/3
Basic Example
1
2
3
4
def f(x,y):
x = x + y
print(x)
return x
5
6
7
8
9
def main():
n = 4
out = f(n,2)
print(out)
main:7
10
11
main()
At the beginning of the program, main is called. We create
a new stack frame. Since main has no parameters, the stack
frame is empty.
2/3
Basic Example
1
2
3
4
def f(x,y):
x = x + y
print(x)
return x
5
6
7
8
9
def main():
n = 4
out = f(n,2)
print(out)
main:7
10
11
main()
When line 7 of main is executed, the variable n is set to the
value 4. We symbolize this by writing the variable name in the
stack frame and creating an object on the heap for the value.
We draw an arrow from the variable to its value.
2/3
Basic Example
1
2
3
4
def f(x,y):
x = x + y
print(x)
return x
5
6
7
8
9
def main():
n = 4
out = f(n,2)
print(out)
main:8
n
4
10
11
main()
When line 7 of main is executed, the variable n is set to the
value 4. We symbolize this by writing the variable name in the
stack frame and creating an object on the heap for the value.
We draw an arrow from the variable to its value.
2/3
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- title clear — clear memory
- memory in python cornell university
- python activity 2 input and variables in python ioct
- what is a variable in python variable naming rules in python
- memory saving tips for circuitpython adafruit industries
- python v3 stack frame examples swarthmore college
- ppyytthhoonn vvaarriiaabbllee ttyyppeess
- python variable types picone press
- c4m the python memory model
- dude where s my ram a deep dive into how python uses memory
Related searches
- examples of college essays
- examples of college research papers
- examples of college essay papers
- essay examples for college application
- examples of college admission essays
- examples of college essays for admission
- examples of college philosophy papers
- examples of college application essays
- journal examples for college students
- examples of college writing assignments
- examples of college essay prompts
- autobiography examples for college students