Lesson 1 in Comp Prog 1 v2 PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document provides an overview of computer programming, including key terms, types of programs, programming languages, and concepts related to program development. It covers different aspects of computer programming including common programming languages and flowcharting.
Full Transcript
Overview of Computer Programming DCSN02C – Computer Programming 1 Date Activity Aug 19-23 Orientation Timeline of Aug 26-30 Lesson 1 Activities Sept 2-5 Lesson 2 Sept 9-12 Sept 16-19 Prelim Exam Objectives Identify and explain th...
Overview of Computer Programming DCSN02C – Computer Programming 1 Date Activity Aug 19-23 Orientation Timeline of Aug 26-30 Lesson 1 Activities Sept 2-5 Lesson 2 Sept 9-12 Sept 16-19 Prelim Exam Objectives Identify and explain the different programming terms Explain the steps in Software development life cycle/steps in problem solving and program development. Apply flowcharting in creating program solutions COMPUTER PROGRAM APPLICATION PROGRAMMING LANGUAGE Key Terms ALGORITHM DEBUGGING SYNTAX ERROR Computer Program a set and sequence of instructions given to the computer, telling it what to do and how to perform the specified task. usually written using a Computer Programming Language. Computer Program A computer program is also called a computer software, which can range from two lines to millions of lines of instructions. Computer program instructions are also called program source code Computer Programming is also called program coding. A computer without a computer program is useless as it has nothing to do. Computer Program 1. Systems Programs. Programs that are needed to keep all the hardware and software systems running together smoothly Examples: Operating Systems like Linux, Windows, Unix, Solaris, MacOS 2. Application Programs. Are programs that people use to get their work done. Examples: Word Processor, Game programs, Spreadsheets 3. Compiler. The computer understands only one language: machine language. Machine language is in the form of ones and zeros. Uses of Computer Program MS Word, MS Excel, Adobe Photoshop, Internet Explorer, Chrome, etc., are examples of computer programs. Computer programs are being used to develop graphics and special effects in movie making. Computer programs are being used to perform Ultrasounds, X-Rays, and other medical examinations. Computer programs are being used in our mobile phones for SMS, Chat, and voice communication. Programming Language is a standardized communication technique for expressing instructions to a computer. Like human languages, each language has its own syntax and grammar. enable a programmer to precisely specify what data a computer will act upon, how these data will be stored/transmitted, and precisely what actions to take under various circumstances Then the act of writing/creating computer program is computer programming Programming Language Common Programming Languages: 1. Python — Artificial Intelligence & Machine Learning 2. JavaScript — Rich Interactive Web Development 3. Java — Enterprise Application Development 4. C/C++ — Operating Systems and System Tools 5. C# — Application & Web Development Using.NET 6. PHP — Web Development 7. SQL — Data Management Computer Programmer Someone who can write computer programs or someone who can do computer programming Types of Programmers: 1. Software Developers 2. Game Programmers 3. Software Engineers 4. Data Developers 5. Web Developers 6. Network System Administrators Categories of Programming Language 1. High-level Programming Languages. A programming language that is more user-friendly, to some extent platform-independent, and abstract from low-level computer processor operations such as memory accesses. A programming statement may be translated into one or several machine instructions by a compiler. “Simply close to human language” Examples are Java, C, C++, python, Ruby 2. Low-level Assembly Language. Assembly languages are similar to machine languages, but they are much easier to program in because they allow a programmer to substitute names for numbers. Assembly languages are available for each CPU family, and each assembly instruction is translated into one machine instruction by an assembler program. Algorithm From programming point of view, an algorithm is a step-by-step procedure to resolve any problem. An algorithm is an effective method expressed as a finite set of well-defined instruction. Instead of providing an answer to a question—or even showing the work for how they got there— algorithmic thinking requires students to solve not for an answer, but for a replicable process to solve the answer (or complete a task). Algorithm Program Development Life Cycle 1. Problem Definition A clearly defined problem is already half the solution. Computer programming requires us to define the problem first before we even try to create a solution. “Create a python program that will ask the user to input two integer number and the program will compute and display for the sum, product, difference and quotient of the two numbers” 2. Problem Analysis After the problem has been adequately defined, the simplest and yet the most efficient and effective approach to solve the problem must be formulated. Usually, this step involves breaking up the problem into smaller and Program simpler sub-problems. Under this stage, Development identify “what is ask in the problem” , “ Identify what are the inputs” and “what Life Cycle process must be done” “Create a python program that will ask the user to input two integer number and the program will compute and display for the sum, product, difference and quotient of the two numbers” 2. Problem Analysis Identify what are the inputs “ Two integer numbers “ , you may assign names under this stage ex, first integer number is num1 and second Program integer number is num2 Development What process must be done? Identify Life Cycle what are the process involve Going back to the given example problem in number 1, the following are the formula needed in order to process the sum, product, difference and quotient of the two numbers. 3. Algorithm design and representation (Pseudocode or flowchart) An Algorithm is a clear and unambiguous specification of the steps needed to solve a problem. It may be expressed in either Program Human language (English, Tagalog), through a graphical representation like a flowchart or Development through a pseudocode, which is a cross between human language and a Life Cycle programming language. Expressing our solution through human language 1. Get the first number and second number 2. Compute for sum, product, difference and quotient 3.Display the sum, product, difference and quotient Program Algorithm design and Development representation (Pseudocode or flowchart) Life Cycle Coding and debugging Syntax errors Runtime errors Occur when a Also known as programmer writes Compile errors execution errors, Program an invalid statement, these errors occur Also known as Development such as misspelling a while the program is compile-time errors, word or missing running and cannot Life Cycle punctuation. Syntax these errors are be detected by the related to syntax or errors are static compiler. They can semantics and can errors that can be be caused by invalid be easily fixed during detected by the or insufficient data, the development compiler and or by things like process. prevent the code dividing by zero or from running until using an uninitialized they are fixed. variable. A flowchart is a design tool used to graphically represent the logic in a solution. Flowcharts typically do not display programming language command. It is a pictorial representation of an Flowcharting algorithm. In flowchart, the steps in the algorithm are represented in the form of different shapes of boxes and the logical flow is indicated by interconnecting arrows. Flowchart Symbols 1. Terminator - The terminator symbol represents the starting or ending point of the system. 2. Process - A box that indicates some particular operation. 3. Document - This represents a printout, such as a document or a report. 4. Decision - A diamond represents a decision or branching point. Lines coming out from the diamond indicates different possible situations, leading to different sub-processes. Flowchart Symbols 5. Data - It represents information entering or leaving the system. An input might be an order from a customer. An output can be a product to be delivered. 6. On-Page Reference - This symbol would contain a letter inside. It indicates that the flow continues on a matching symbol containing the same letter somewhere else on the same page. 7. Off-Page Reference - This symbol would contain a letter inside indicating that the flow continues on a matching symbol containing the same letter somewhere else on a different page. Flowchart Symbols 8. Delay or Bottleneck - Identifies a delay or a bottleneck. 9. Flow - Lines represent flow of the sequence and direction of a process. Terminal / Terminator The terminator shows where your process begins or ends. You can use words like ‘Start’, ‘Begin’, ‘End’ inside the terminator shape to make things more obvious. Data (I/O) The Data object, often referred to as the I/O Shape shows the Inputs to and Outputs from a process. This takes the shape of a parallelogram. Process / Rectangle Flowchart process shape is used to represent a process, action step, or operation. While these are pictured with rectangles, the text in the rectangle mostly includes a verb. Decision / Conditional This object is always used in a process flow to ask a question. And, the answer to the question determines the arrows coming out of the Diamond. Document The document object is a rectangle with a wave-like base. This shape is used to represent a Document or Report in a process flow. Document The document object is a rectangle with a wave-like base. This shape is used to represent a Document or Report in a process flow. Guidelines for preparing proper flowchart The flowchart should be neat and easy to follow so that it will be clearly understood. A logical start and end must be given to the flowchart. The flowchart should include necessary steps in logical order. Guidelines for preparing proper flowchart The only one flow line should come out from a process symbol. The decision making symbol should have only one incoming flow line. However, it may have two or 6 three out-going flowlines. Guidelines for preparing proper flowchart The terminal symbols, that is, Start and Stop / End symbols should have only one flow line. 7 The symbol should contain the information (process, data or text) clearly to carry out the required 8 action. Guidelines The number of flow-lines can be reduced for using connector symbol. The connectors are mainly required in complex flowcharts. preparing The intersected flow-lines should be avoided. This makes the flowchart effective proper and represents communication clearly. The correctness of the flowchart can be flowchart tested by passing the test data through it. It becomes the validity test of the flowchart. Examples for Flow Chart Flow Chart Example 1 We will now draw a flow chart for having a bath. We start by thinking about the steps involved: (1) Fill the bath with water (2) Get undressed. (3) Get into bath. (4) Wash. (5) Get out of bath. (6) Empty the bath water. (7) Get dressed. Examples for Flow Chart Flow Chart Example 2 The step Fill the bath with water in the previous example could have been more detailed. For example, you need to check if there is enough water and whether it is at the right temperature while running the bath. Again we need to think about the steps involved: (1) Turn on the hot and cold taps. (2) Is it too hot or cold? If it is, go to step 3, otherwise go to step 4. (3) Adjust the hot and cold taps and go back to step 2. (4) Wait for 2 minutes. (5) Is the bath full? If it is, go to step 7, otherwise go to step 6. (6) Go back to step 4. (7) Turn off the hot and cold taps. Examples for Flow Chart Flow Chart Example 3 The flow chart on the right is meant to show the steps for safely crossing the road. There is a decision box in this flow chart. The steps involved: Cross the road carefully Look left and right Stop at the kerb Is the road clear both ways? Flowchart Sample Problem 1 Create program that will ask the user to input a value for temperature. If the temperature is less than 32, display the statement “Above Freezing” if the temperature is greater than 32 display “Below Freezing” Flowchart Sample Problem 2 Create program that will ask the user to input a value for a number. Check whether if it’s an odd or even number then display the remainder of that given number Flowchart Sample Problem 3 Create program that will ask the user to input a value for four major exam. The program will compute for the average of four major exam grade. If the computed grade is greater than 60 display “PASS” otherwise display “FAIL” Flowchart Sample Problem 4 Create program that will ask the user to input a number as value of n. The program will continuously ask the user to input a number and compute for sum of the input number and it stop asking for number if the user had already entered five numbers. It will display for total of all input numbers. Flowchart Sample Problem 5 Create program that will continuously ask the user to input for a number, the program will compute for sum of all numbers. It only allows the user to enter ten numbers. Finally, if there were already 10 numbers, it will display for the average of all input numbers.