1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.
-
Upload
kathryn-burke -
Category
Documents
-
view
240 -
download
0
description
Transcript of 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.
![Page 1: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/1.jpg)
1
Programming for Engineers in
Python
Autumn 2011-12
Lecture 8: Recursion
![Page 2: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/2.jpg)
2
Lecture 7: Highlights
![Page 3: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/3.jpg)
3
Lecture 6 (OOP): Highlights• Representation design options and implications (Rectangle)• Inheritance and Polymorphism• Rational - customize classes so that they are natural to use
• Attributes, methods, constructor• Method overriding (e.g., __str__)• Operators overloading (e.g., __add__)
![Page 4: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/4.jpg)
4
Variables in Functions• Defined only in the function’s scope• Are not available for other functions/shell (even function’s parameters)• Upon completion of execution:
•Variables are not defined anymore•Variables values are not kept for future invocations of the function
![Page 5: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/5.jpg)
5
The Call Stack
call stack
resultmain
base
exponent
res
ipower
= 2
= 20
= 3
= 15
= 5
= 17
![Page 6: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/6.jpg)
6
Towers of Hanoi
• Objective:• Move the entire stack of disks from rode S
(source) to T (target) using A (auxiliary)
S TA
![Page 7: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/7.jpg)
7
The Rules
• Only one disk may be moved at a time• Each move consists of taking the upper disk from one
of the rods and sliding it onto another rod• No disk may be placed on top of a smaller disk
S TA
![Page 8: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/8.jpg)
8
Examples
S TA
1 disk – very easy!
S TA
2 disks – very easy!
S TA3 disks – easy
S TA4 disks?
![Page 9: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/9.jpg)
9
Solution for 4 Disks
S TA
S TA
S TA
S TA
![Page 10: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/10.jpg)
10
For n Disks?
S TA
![Page 11: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/11.jpg)
11
Assume We Have a Solution for n-1 Disks
S TA
![Page 12: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/12.jpg)
12
Solution: Step 1
S TA
![Page 13: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/13.jpg)
13
Solution: Step 2
S TA
![Page 14: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/14.jpg)
14
Solution: Step 3
S TA
![Page 15: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/15.jpg)
15
How to Solve for n-1 Disks?
Easy!
![Page 16: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/16.jpg)
16
Algorithm for n Disks
S TA
1. If there is only a single disk – easy!2. Move n-1 disks from S to A (T is the auxiliary rode)3. Move disk from S to T4. Move n-1 disks from A to T (S is the auxiliary rode)
Let us write it in Python…
![Page 17: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/17.jpg)
17
A Python Program for Towers of Hanoi
![Page 18: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/18.jpg)
18
Remember the Calling Stack?
hanoi(3,'S','T','A')main
hanoi(2,'S',‘A',‘T')
hanoi(1,‘S',‘T',‘A')
And so on…
![Page 19: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/19.jpg)
19
Recursion
• We use Recursion to solve the Towers of Hanoi problem
• Recursion: a function whose implementation references itself
• Recursion enables to solve a “large” problem using solutions to “small” problems that assemble it
• In every recursive call the problem is reduced. When the problem is small enough -solve directly (base case, מקרה קצה)
• Divide and conquer
![Page 20: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/20.jpg)
20
Iterative Versus Recursive
Step by step (iteratively): 4! = 1*2*3*4 = 2*3*4 = 6*4 = 2424 = 2*2*2*2 = 4*2*2 = 8*2 = 16
n! = 1*2*3*….*nan = a*a*…..*a
n iterations
n! = n*(n-1)!0! = 1
Recursively: 4! = 4*3! = 4*(3*2!) = 4*(3*(2*1!)) = 4*(3*(2*(1*0!))) = 4*(3*(2*(1*1))) = 4*(3*(2*1)) = 4*(3*2) = 4*6 = 24
![Page 21: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/21.jpg)
21
Recursive Definition
n! = n*(n-1)!0! = 1
Base condition
קצה מקרה
Recursive call
Smaller instance
Factorial
![Page 22: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/22.jpg)
22
Pros and Cons
• Pros: short and natural for many problems• Cons: Computational inefficient, sometimes hard to
understand or inconvenient
![Page 23: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/23.jpg)
23
Recursion Example in Python
Halting condition (and infinite loops)
Advance towards base case
![Page 24: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/24.jpg)
24
Recursive factorial – step by step
factorial(4)n4
Returns…
![Page 25: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/25.jpg)
25
Recursive factorial – step by step
factorial(4)n4
Returns…4*…
![Page 26: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/26.jpg)
26
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
![Page 27: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/27.jpg)
27
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
![Page 28: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/28.jpg)
28
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…3*…
![Page 29: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/29.jpg)
29
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
![Page 30: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/30.jpg)
30
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
![Page 31: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/31.jpg)
31
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…2*…
![Page 32: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/32.jpg)
32
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…
![Page 33: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/33.jpg)
33
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…
![Page 34: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/34.jpg)
34
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…1*…
![Page 35: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/35.jpg)
35
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…
factorial(0)n0
Returns…
![Page 36: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/36.jpg)
36
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…
factorial(0)n0
Returns…
![Page 37: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/37.jpg)
37
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…
factorial(0)n0
Returns…
![Page 38: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/38.jpg)
38
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…
factorial(0)n0
Returns… 1
![Page 39: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/39.jpg)
39
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…
factorial(1)n1
Returns…1*1
![Page 40: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/40.jpg)
40
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…
factorial(2)n2
Returns…2*1
![Page 41: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/41.jpg)
41
Recursive factorial – step by step
factorial(4)n4
Returns…
factorial(3)n3
Returns…3*2
![Page 42: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/42.jpg)
42
Recursive factorial – step by step
factorial(4)n4
Returns…4*6
![Page 43: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/43.jpg)
43
General Form of Recursive Algorithms
• Base case: small (non-decomposable) problem• Recursive case: larger (decomposable) problem• At least one base case, and at least one recursive
case.
test + base case
recursive case
![Page 44: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/44.jpg)
44
Short Summary
• Design a recursive algorithm by1. Solving big instances using the solution to smaller
instances2. Solving directly the base cases
• Recursive algorithms have1. Stopping criteria2. Recursive case(s)3. Construction of a solution using solution to smaller
instances
![Page 45: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/45.jpg)
45
Point for Attention: Memory
• Variables of a called function are kept in memory until the function returns
• Many recursive calls might fill the computers memory
• Even if we minimize the number of variables, recursion has its price
![Page 46: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/46.jpg)
46
Example: Fibonacci Series
• Fibonacci series0, 1, 1, 2, 3, 5, 8, 13, 21,
34• Definition:
• fib(0) = 0• fib(1) = 1• fib(n) = fib(n-1) + fib(n-2)
en.wikipedia.org/wiki/Fibonacci_number
![Page 47: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/47.jpg)
47
סלט פיבונאצ'י
![Page 48: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/48.jpg)
48
Recursive Fibonacci Series
Every call with n > 1 invokes 2 function calls, and so on…
![Page 49: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/49.jpg)
49
Redundant Calls
Fib(4)
Fib(3) Fib(2)
Fib(2) Fib(1) Fib(1) Fib(0)
Fib(1)
Fib(0)
Fib(5)
Fib(3)
Fib(2) Fib(1)
Fib(1)
Fib(0)
![Page 50: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/50.jpg)
50
Number of Calls to Fibonacci
n value Number of calls
1 1 1
2 1 3
3 2 5
23 28657 92735
24 46368 150049
![Page 51: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/51.jpg)
51
Demonstration: Iterative Versus Recursive Fibonacci
![Page 52: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/52.jpg)
52
Demonstration: Iterative Versus Recursive Fibonacci
Output (shell):
![Page 53: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/53.jpg)
53
Fibonacci: Recursion and Efficiency
• If a recursive function calls itself more than once it will be extremely inefficient
• Define it iteratively
![Page 54: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/54.jpg)
54
So Do We Really Need Recursion?
Yes!
(specific examples next week)
![Page 55: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/55.jpg)
55
Odd-Even (if time allows)
• Given a function ‘odd(n)’ • Odd n - return True, Even n – return False
• Write a function ‘even(n)’ that:• Even n - return True, Odd n – return False
• This is easy!
![Page 56: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/56.jpg)
56
Odd-Even
![Page 57: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/57.jpg)
57
Odd-Even
![Page 58: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/58.jpg)
58
Odd-Even
![Page 59: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/59.jpg)
59
Odd-Even
![Page 60: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/60.jpg)
Questions?
![Page 61: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/61.jpg)
61
Off Topics• Documenting your programs• Find the error
![Page 62: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/62.jpg)
62
Documenting Your Programs
• An essential part of writing computer code• Understand what was your intension when
writing it• For others to be able to coordinate their
code with yours• For the grader/lecturer to try and understand
your code and grade it accordingly…
![Page 63: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/63.jpg)
63
Documenting Your Programs with Comments
• Comments: pieces of code not interpreted or executed by the computer
• One line comments start with the hash character (#)
![Page 64: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/64.jpg)
64
Meaningful Variables Names
• Variables names• Meaningful names
![Page 65: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/65.jpg)
Off Topic: Find the Error
![Page 66: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/66.jpg)
And Now?
![Page 67: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/67.jpg)
And Now?
![Page 68: 1 Programming for Engineers in Python Autumn 2011-12 Lecture 8: Recursion.](https://reader036.fdocuments.net/reader036/viewer/2022062414/5a4d1be87f8b9ab0599e2c61/html5/thumbnails/68.jpg)
INDENTATION IS REALLY, REALLY IMPORTANT!