LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
PSEUDOCODE & FLOW CHART
Flow Control Analysis & Design Tool: Flowcharts
CS1010 Programming Methodology
ITEC113 Algorithms and Programming Techniques
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Problem Solving and Program Design Programming. COMP104 Lecture 3 / Slide 2 Problem Solving Process l Define and analyze the problem. l Develop a solution.
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Computer Science 1620 Programming & Problem Solving.
General Computer Science for Engineers CISC 106 Lecture 26 Dr. John Cavazos Computer and Information Sciences 04/24/2009.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Chapter 1 Program Design
Chapter 1 Pseudocode & Flowcharts
Programming is instructing a computer to perform a task for you with the help of a programming language.
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Software Engineering 1 (Chap. 1) Object-Centered Design.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Adapted from slides by Marie desJardins
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
High-Level Programming Languages: C++
1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs.
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
CIS Computer Programming Logic
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
CSC141 Introduction to Computer Programming
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Flowcharts.
Previously Repetition Structures While, Do-While, For.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 2.
Review the following : Flowcharting Variable declarations Output Input Arithmetic Calculations Conditional Statements Loops.
1 Original Source : and Problem and Problem Solving.ppt.
REPETITION STATEMENTS - Part2 Structuring Input Loops Counter-Controlled Repetition Structure Sentinel-Controlled Repetition Structure eof()-Controlled.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Software Engineering Algorithms, Compilers, & Lifecycle.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
Problem Solving and Program Design. Problem Solving Process Define and analyze the problem. Develop a solution. Write down the solution steps in detail.
All materials copyright UMBC unless otherwise noted CMSC201 Computer Science I for Majors Lecture 02 – Algorithmic Thinking.
Introduction to Computer Programming
CMSC201 Computer Science I for Majors Lecture 02 – Algorithmic Thinking Prof. Katherine Gibson Based on slides by Shawn Lupoli and Max Morawski at UMBC.
Engineering Problem Solving With C An Object Based Approach
Chapter 1. Introduction to Computers and Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Let’s all Repeat Together
CS 1111 Introduction to Programming Spring 2019
Life is Full of Alternatives
Life is Full of Alternatives
Presentation transcript:

LECTURE 1 CMSC 201

Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered steps to accomplish a task Algorithm Representation - Pseudocode or flowchart

Program Development Step 1: Understand the problem (input, process, output) Step 2: Represent algorithm in pseudocode or flowchart Step 3: Desk check the algorithm Step 4: Implement in a programming language (We will use Python, other options include C, C++, Java, etc.) Step 5: Test/Debug your program

Example Develop an algorithm that will calculate an hourly employee’s weekly pay When developing algorithms, we have 3 control structures available to us 1. Sequence (i.e. one line after the other) 2. Decision making (e.g. using if/else constructs) 3. Looping (e.g. using while loops) Step 1 : Understand the problem Input : pay rate and number of hours Process: pay = rate * hours Output: pay

Example - Pseudocode Pseudocode - looks like code, but not a real language Step 2: 1. Variables: hours, rate, pay 2. Display “Number of hours worked: ” 3. Get hours 4. Display “Amount paid per hour: ” 5. Get rate 6. pay = hours * rate 7. Display “The pay is $”, pay Notice the importance of order and lack of ambiguity

Basic Flowchart Symbols SymbolName Start Symbol End Symbol Input/Output Data Processing Symbol Decision Symbol Flow Control Arrows Start End

Example - Flowchart Start End Display “Number of hours worked: ” Get hours Display “Amount paid per hour: ” Get rate pay = hours * rate Display “The pay is $”, pay

Flowcharts – Decision Making example If num > 0 display “Positive” Else (that means 0 or negative) display “Not Positive” num >0? Display “positive” Display “Not positive” True False

Flowcharts – Looping example Get books books >= 0? True False Display ”Error, enter number of books read: “ Get books Keep prompting the user for the number of books as long as the input is non-positive

Back to the original example Step 3: Line # Variable Declarations hoursratepayOutput 1hours, rate, pay 2 Number of hours worked: Amount paid per hour: The pay is $800

Stored-Program Computer Step 4: So far, everything has been on paper. How do we get it to run on a computer? 1. Design a computer specific to solving this one problem (Not a good idea, although historically early computers were designed to just solve specific problems) 2. Use a stored-program computer (A more general approach where data/instructions are in memory and the CPU processes the code)

Basic Computational Model CPU Code/Data Memory Input Output

Computer Program Algorithm development should be independent of the final computer language used to implement the algorithm as an executable program Algorithm development is the hard part Example Algorithm Python Program

Example: Program in C++ /************************************** C++ Implementation of the algorithm. **************************************/ #include using namespace std; int main() { //declare the variables double hours, rate, pay; //Get user input cout << "Number of hours worked: "; cin >> hours; cout << "Amount paid per hour: "; cin >> rate; //Calculate the pay pay = hours * rate ; //Display the result cout << "The pay is $” << pay <<endl; return 0; } Step 4: Let’s write the program in Python (We will learn the Python programming language this semester)

Python Interpreter Python Interpreter – runs your python code Can use it in the interactive mode or script mode Your code is compiled into byte code (.pyc file) Python Virtual Machine (PVM) runs the byte code