Lecture 6 Recursion
Lecture 6 - Recursion
Review:Abstraction
Review: Abstraction
Describing Functions def square(x): """Return X X""" A function's domain is the set of all inputs it might possibly take as arguments. x is a number A function's range is the set of output values it might square returns a non- possibly return. negative real number A pure function's behavior is the relationship it creates square returns the square of x between input and output
Describing Functions A function's domain is the set of all inputs it might possibly take as arguments. A function's range is the set of output values it might possibly return. A pure function's behavior is the relationship it creates between input and output. def square(x): """Return X * X""" x is a number square returns a nonnegative real number square returns the square of x
Functional Abstraction Demo Mechanics Use (functional abstraction) How does Python execute this program square(2)always returns 4 line-by-line(e.g.Python Tutor) ● square(3)always returns 9 What happens when you evaluate a call expression,what goes on its body,etc. Without worrying about how Python evaluates the function
Functional Abstraction Mechanics How does Python execute this program line-by-line (e.g. Python Tutor) What happens when you evaluate a call expression, what goes on its body, etc. Use (functional abstraction) ● square(2) always returns 4 ● square(3) always returns 9 ● ... Without worrying about how Python evaluates the function Demo
Recursion
Recursion