11 slide presentation

# 11 slide presentation - Engineering Computation Tutorial 11...

This preview shows pages 1–6. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Engineering Computation: Tutorial 11 Problem Solving with Computing, using the Python Language What’s in your toolbox? Print statement, string literals Basic calculator, integer division Variables Built-in functions Math library functions Straight-line programs Branching programs Python lists For loops Nested for loops Strings While loops Converting between number system using Python Matplotlib Program Design File Processing Graphics Functions Scope of Variables Comments Complex Conditions Testing and Debugging Exception Handling Common Loop Patterns Boolean Operators Unit Testing Classes and Objects Data Collections Searching and Sorting 2 Today’s Topics: 1 Recursion 3 Recall: Functions can call other functions. Let f 1 be the function that maps an integer n to the integer f 1 ( n ) = n 2 Let f 2 be the function that maps an integer n to the integer f 2 ( n ) = n X i =0 f 1 ( i ) = f 1 (0) + ··· + f 1 ( n ) if n ≥ if n < f 1 implementation def fun1 (n ) : return n ** 2 *pyramid of golfballs f 2 implementation def fun2 (n ) : sum = 0 for i in range (n+1) sum += fun1 ( i ) return sum 4 Functions that call themselves.Functions that call themselves....
View Full Document

## This note was uploaded on 10/14/2011 for the course ENGINEER CHEM ENG 3 taught by Professor Ghosh during the Spring '11 term at McMaster University.

### Page1 / 19

11 slide presentation - Engineering Computation Tutorial 11...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online