Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming Professor Sprenkle September 10, 2007.

Similar presentations


Presentation on theme: "Introduction to Programming Professor Sprenkle September 10, 2007."— Presentation transcript:

1 Introduction to Programming Professor Sprenkle sprenkles@wlu.edu September 10, 2007

2 Sep 10, 2007Sprenkle - CS1112 Objectives Introduction to problem solving Introduction to problem solving Introduction to Python Introduction to Python Introduction to Linux Introduction to Linux

3 Sep 10, 2007Sprenkle - CS1113 Computational Problem Solving 101 Computational Problem Computational Problem  A problem that can be solved by logic To solve the problem: To solve the problem:  Create a model of the problem  Design an algorithm for solving the problem using the model  Write a program that implements the algorithm

4 Sep 10, 2007Sprenkle - CS1114 Computational Problem Solving 101 Algorithm: a well-defined recipe for solving a problem Algorithm: a well-defined recipe for solving a problem  Has a finite number of steps  Completes in a finite amount of time Program Program  An algorithm written in a programming language  Also called code Application Application  Large programs, solving many problems

5 Sep 10, 2007Sprenkle - CS1115 More on Algorithms Algorithms often have a defined type of input and output. Algorithms often have a defined type of input and output. Correct algorithms give the intended output for a set of input. Correct algorithms give the intended output for a set of input. Example: Multiply by 10 Example: Multiply by 10  I/O for a correct algorithm: 5,50 5,50.32, 3.2.32, 3.2 x, 10x x, 10x More examples: Long division, recipes More examples: Long division, recipes input algorithm output IO

6 Sep 10, 2007Sprenkle - CS1116 Making a Peanut Butter & Jelly Sandwich How do you make a peanut butter and jelly sandwich? How do you make a peanut butter and jelly sandwich? Write down the steps so that someone else can follow your instructions Write down the steps so that someone else can follow your instructions  Make no assumptions about the person’s knowledge of PB&J sandwiches  The person has the following materials: Loaf of bread, Jar of PB, Jelly, 2 Knives, paper plates, napkins Loaf of bread, Jar of PB, Jelly, 2 Knives, paper plates, napkins

7 Sep 10, 2007Sprenkle - CS1117 Discussion of PB&J The computer: a blessing and a curse The computer: a blessing and a curse  Recognize and meet the challenge! Be unambiguous, descriptive Be unambiguous, descriptive  Must be clear for the computer to understand  “Do what I meant! Not what I said!” Creating/Implementing an algorithm Creating/Implementing an algorithm  Break down pieces  Try it out  Revise

8 Sep 10, 2007Sprenkle - CS1118 Discussion of PB&J Be prepared for special cases Be prepared for special cases Aren’t necessarily spares in real life Aren’t necessarily spares in real life  Need to write correct algorithms! Reusing similar techniques Reusing similar techniques  Do the same thing with a little twist Looping Looping  For repeating the same action

9 Sep 10, 2007Sprenkle - CS1119 Parts of an Algorithm Primitive operations Primitive operations  What data you have, what you can do to the data Naming Naming  Identify things we’re using Sequence of operations Sequence of operations Conditionals Conditionals  Handle special cases Repetition/Loops Repetition/Loops Subroutines Subroutines  Call, reuse similar techniques An overview for the semester!

10 Sep 10, 2007Sprenkle - CS11110 Other Lessons To Remember A cowboy’s wisdom: Good judgment comes from experience A cowboy’s wisdom: Good judgment comes from experience  How can you get experience?  Bad judgment works every time Program errors can have bad effects Program errors can have bad effects  Prevent the bad effects--especially before you turn in your assignment!

11 Sep 10, 2007Sprenkle - CS11111 Computational Problem Solving 101 Computational Problem Computational Problem  A problem that can be solved by logic To solve the problem: To solve the problem:  Create a model of the problem  Design an algorithm for solving the problem using the model  Write a program that implements the algorithm

12 Sep 10, 2007Sprenkle - CS11112 Programming Languages Programming language: Programming language:  Specific rules for what is and isn’t allowed  Must be exact  Computer carries out commands as they are given Syntax: the symbols given Syntax: the symbols given Semantics: what it means Semantics: what it means Example: III * IV = 3 x 4 = 12 Example: III * IV = 3 x 4 = 12 Programming languages are unambiguous Programming languages are unambiguous

13 Sep 10, 2007Sprenkle - CS11113 Python A common interpreted programming language A common interpreted programming language First released by Guido van Rossum in 1991 First released by Guido van Rossum in 1991 Named after Monty Python’s Flying Circus Named after Monty Python’s Flying Circus Minimalist syntax, emphasizes readability Minimalist syntax, emphasizes readability Flexible, fast, useful language Flexible, fast, useful language Used by scientists, engineers, systems programmers Used by scientists, engineers, systems programmers

14 Sep 10, 2007Sprenkle - CS111 Python Interpreter Simulates a computer Simulates a computer Gives user immediate feedback Gives user immediate feedback  E.g., if program contains error Behind the scenes: interpreter (a program itself) turns each expression into bytecode and then executes the expression Behind the scenes: interpreter (a program itself) turns each expression into bytecode and then executes the expression Interpreter (python) Python expression Output Executable bytecode

15 Sep 10, 2007Sprenkle - CS11115 The Programming Process 1. Programmer types a program/script into a text editor (jEdit or IDLE). 2. An interpreter (a program itself) turns each expression into bytecode and then executes each expression Interpreter (python) Program text file program.py Output Text Editor (jEdit or IDLE) Executable bytecode

16 Sep 10, 2007Sprenkle - CS11116 UNIX/Linux operating system Operating system Operating system  Manages the computer’s resources, e.g., CPU, memory, disk space  Examples: UNIX, Windows XP, Windows 2000, Mac OSX, Linux, etc. UNIX/Linux UNIX/Linux  Command-line interface (not a GUI)  Type commands into terminal window  Example commands: cp file1.c file1copy.c (copy a file) cp file1.c file1copy.c (copy a file) mkdir cisc105 (make a directory) mkdir cisc105 (make a directory)

17 Sep 10, 2007Sprenkle - CS11117 The Programming Process In a Linux terminal:  jedit &  or idle &  python  E.g., python hello.py Interpreter (python) Program text file program.py Output Text Editor (jEdit or IDLE) Executable bytecode


Download ppt "Introduction to Programming Professor Sprenkle September 10, 2007."

Similar presentations


Ads by Google