























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























def func_name(par1, par2 = 5): return par1 + par
func_name(4,9) func_name(3)
Functions that return Boolean values def is_divisible_by_2(num): return (num % 2 == 0)
Preconditions Postconditions
A technique that solves problem by solving smaller versions of the same problem!
When you turn this into a program, you end up with functions that call themselves (i.e., recursive functions )
n! = n*(n-1)! f(n) = n * f(n-1)
0, 1, 1, 2, 3, 5, 8, 13…
f(n) = f(n-1) + f(n-2) where f(0) = 1 f(1) = 1
A string is a sequence of characters A string literal uses quotes 'Hello' or “Hello” For strings, + means “concatenate” When a string contains numbers, it is still a string
Computations on string start at the beginning, select each character in turn, do something to it, and continue until the end. This pattern of processing is called a traversal.