Agenda
- Announcements
- Snarf code “CompSci101Recursion”
1/14/2013 CompSci101 Peter Lorensen 1
Agenda Announcements Snarf code CompSci101Recursion 1/14/2013 - - PowerPoint PPT Presentation
Agenda Announcements Snarf code CompSci101Recursion 1/14/2013 CompSci101 Peter Lorensen 1 Recusion Recusion: Se recusion. 1/14/2013 CompSci101 Peter Lorensen 2 Recursion Functions can call other functions, but they
1/14/2013 CompSci101 Peter Lorensen 1
1/14/2013 CompSci101 Peter Lorensen 2
1/14/2013 CompSci101 Peter Lorensen 3
1/14/2013 CompSci101 Peter Lorensen 4
1/14/2013 CompSci101 Peter Lorensen 5
def countdown(n): if n == 0: print 'Blastoff!' else: print n countdown(n - 1) countdown(5)
1/14/2013 CompSci101 Peter Lorensen 6
1/14/2013 CompSci101 Peter Lorensen 7
1/14/2013 CompSci101 Peter Lorensen 8
1/14/2013 CompSci101 Peter Lorensen 9
1/14/2013 CompSci101 Peter Lorensen 10
def countdown(n): if n == 0: print 'Blastoff!' else: print n countdown(n - 1) countdown(5)
1/14/2013 CompSci101 Peter Lorensen 11
def vatCalculator( meatLst ): vat = 7.25 if len( meatLst ) == 0: print "Done" else: pay = meatLst[0] tax = (pay * vat) / 100.0 print pay, tax, “," vatCalculator(meatLst) lionFood = [10.0, 1000.0, 100.0 ] vatCalculator( lionFood )
1/14/2013 CompSci101 Peter Lorensen 12