{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

t_04.4up

# t_04.4up - Questions from Week 03 Engineering Computation...

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

Engineering Computation: Tutorial 04 Problem Solving with Computing, using the Python Language Questions from Week 03? Programming Exercises from Zelle textbook 1 Pg. 118 # 1, 2, 9, 12, 14. 2 What’s in your toolbox? 1 Print statement, string literals 2 Basic calculator, integer division 3 Variables 4 Built-in functions 5 Math library functions 6 Straight-line (non-branching) programs 7 Branching programs 8 Python lists 9 For loops 10 Nested for loops 11 Strings 12 Converting between number system using Python 13 Matplotlib 3 Today’s Topics: Program Design 1 Pseudo Code 2 Flow Charts 3 Algorithms 4

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

View Full Document
Pseudo Code What is it? Informal description of a process/recipe. Description of a program in English. Abstracts out the details of implementation. Easier for non programmers to understand the workings of the program. Why use it? Part of the design process. Used before a coder starts making the actual program. Every person should be able to understand. Looks like reading some bullet points in simple language. Can be translated into any programming language. 5 Program Design - Pseudo Code if instruction (binary bypass) has the form: if (condition) (instruction) Example pseudocode if (today is Friday) (go to eng1D04 lecture) Example Python Code Friday = raw_input("Is today Friday? y/n ") if Friday == "y": print "Go to eng1d04 lecture." 6 Program Design - Pseudocode if/else instruction (binary choice) has the form: if (condition) (instruction A) else (instruction B) Example Pseudocode if (Today is Saturday, or Today is Sunday) (Stay home) else (Go to school) Example Python Code Today = raw_input("What weekday is it today? ") if (Today == "Saturday" or Today == "Sunday"): print "Stay home." else: print "Go to school!" 7 Program Design - Pseudo Code countable loop has the form: repeat (variable) from START to END (instruction) Example Pseudocode repeat index from 1 to 18 print index Example Python Code for index in range (1 ,19) print index 8
Python versus Pseudo Code You have seen pseudo code in your textbook. Python code can be quite close to pseudo code. In pseudo code, you abstract away the details of the

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.

{[ snackBarMessage ]}

### Page1 / 9

t_04.4up - Questions from Week 03 Engineering Computation...

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

View Full Document
Ask a homework question - tutors are online