Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 6 Program Design 4/18/09 Python Mini-Course: Day 2 - Lesson 6 1.

Slides:



Advertisements
Similar presentations
An Introduction to Programming General Concepts. What is a program? A program is an algorithm expressed in a programming language. programming language.
Advertisements

Programming Paradigms and languages
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
زبانهای برنامه سازی برنامه سازی پیشرفته ارائه دهنده دکتر سيد امين حسيني E.mail: Home page:
Introduction To System Analysis and Design
Computers: Tools for an Information Age
Program Flow Charting How to tackle the beginning stage a program design.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
Objectives Machine language vs.. High-level language Procedure-oriented, object-oriented, and event- driven languages Background of Visual Basic VB Integrated.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction To System Analysis and design
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Programming Languages: Telling the Computers What to Do Chapter 16.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
CIS Computer Programming Logic
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
CS 363 Comparative Programming Languages
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
1 2. Program Construction in Java Programming Fundamentals.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
The Programming Process Define the problem* Make or buy software? Design the program * Code (write) the program Test (debug) the program Document the.
1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
 Programming Language  Object Oriented Programming  JAVA – An Introduction  JAVA Milestones  JAVA Features.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
CS 3050 Object-Oriented Analysis and Design. Objectives What is “Object-Oriented?” Object-Oriented Approach Vs. Structured Approach How Has the Object-Oriented.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Java Fundamentals Usman Ependi UBD
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Programming Languages
Programming and Languages Dept. of Computer and Information Science IUPUI.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
Chapter 2 Principles of Programming and Software Engineering.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Procedural programming Procedural programming is where you specify the steps required. You do this by making the program in steps. Procedural programming.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Programming paradigms
Sections Basic Concepts of Programming
CSCI-235 Micro-Computer Applications
An Introduction to Programming
Introduction to Computer Programming
Computer Programming.
Programming Languages
The Programming Process
ICT Programming Lesson 5:
An Introduction to Programming
Presentation transcript:

Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 6 Program Design 4/18/09 Python Mini-Course: Day 2 - Lesson 6 1

Lesson objectives 1. Describe the four major programming paradigms that can be used in Python 2. List the steps in the program design process 3. Use pseudocode to develop the logic for a simple algorithm 4/18/09 Python Mini-Course: Day 2 - Lesson 6 2

Sources Wikipedia /18/09 Python Mini-Course: Day 2 - Lesson 6 3

Programming paradigms The fundamental styles of computer programming Paradigms describe concepts and abstractions used to represent the elements of a program the steps that compose a computation 4/18/09 Python Mini-Course: Day 2 - Lesson 6 4

Programming paradigms Imperative / Procedural Fortran, COBOL, Pascal, BASIC Functional Mathematica, R Object-oriented (OOP) C++, Java, Python Event-driven 4/18/09 Python Mini-Course: Day 2 - Lesson 6 5

Procedural programming Programs are step-by-step instructions of how to perform a task Specify a series of algorithmic steps Emphasizes use of re-usable procedures (a.k.a functions) to change the program state 4/18/09 Python Mini-Course: Day 2 - Lesson 6 6

Procedural programming in Python # create empty list target = [] # iterate over each thing in source for item in source_list: trans1 = G(item) trans2 = F(trans1) # add transformed item to target target.append(trans2) 4/18/09 Python Mini-Course: Day 2 - Lesson 6 7

Functional programming Based on the lambda calculus Programs are based on the systematic evaluation of mathematical functions Programs describe what to do, not how to do it 4/18/09 Python Mini-Course: Day 2 - Lesson 6 8

Functional programming in Python # Define how to apply two generic # transformations compose2 = lambda A, B: \ lambda x: A(B(x)) # Apply two specific functions # F and G to each item in source target = \ map(compose2(F, G), source_list) 4/18/09 Python Mini-Course: Day 2 - Lesson 6 9

Object-oriented programming Programs are collections of “objects” that interact Objects have attributes and behaviors, much like things in the real world 4/18/09 Python Mini-Course: Day 2 - Lesson 6 10

OOP in Python Python is inherently OOP Everything in Python is an object We’ll discuss OOP in detail on Days 6 and 7 Example: see oop.py 4/18/09 Python Mini-Course: Day 2 - Lesson 6 11

Event-driven programming The flow of the program is determined by events user actions (mouse clicks, key presses, etc.) messages from other programs sensor outputs Used for GUIs 4/18/09 Python Mini-Course: Day 2 - Lesson 6 12

Event-driven programming Programs have two sections Event detection Event handling Example: StudyXXX.py 4/18/09 Python Mini-Course: Day 2 - Lesson 6 13

Program design process 1. Identify the program components you will need Functions, object classes, event handlers, etc. 2. Design the interfaces and stub them out Keep in mind the principles of encapsulation and generalization 4/18/09 Python Mini-Course: Day 2 - Lesson 6 14

Program design process 3. Write a test routine 4. Fill in the program components. Test and debug them 5. Write the main routine 6. Test and debug the program 4/18/09 Python Mini-Course: Day 2 - Lesson 6 15

Pseudocode Pseudocode is a compact and informal high-level description of an algorithm Uses the structural conventions of some programming language Is intended for human reading rather than machine reading Omits details that are not essential for human understanding of the algorithm 4/18/09 Python Mini-Course: Day 2 - Lesson 6 16

Pseudocode example bubbleSort for a list of sortable items: start loop set swapped = false for each item in the list (except the last one) if item > next_item then swap( item, next_item ) set swapped = true end if end for loop if swapped is true then repeat loop end loop 4/18/09 Python Mini-Course: Day 2 - Lesson 6 17

Using pseudocode Purpose Easy for humans to understand Is a compact and environment- independent description of the key principles of an algorithm Useful for: sketching out the structure of the program before coding documenting algorithms for publication 4/18/09 Python Mini-Course: Day 2 - Lesson 6 18