BASIC PROGRAMMING FOR DATA ANALYSIS

Slides:



Advertisements
Similar presentations
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Advertisements

Programming Types of Testing.
Algorithms and flow charts
ITEC113 Algorithms and Programming Techniques
Chapter 3 Planning Your Solution
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
CSC141 Introduction to Computer Programming
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Software Life Cycle What Requirements Gathering, Problem definition
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
1 © 2002 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Structured Programming (4 Credits)
The Hashemite University Computer Engineering Department
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Software. Introduction n A computer can’t do anything without a program of instructions. n A program is a set of instructions a computer carries out.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
 Problem Analysis  Coding  Debugging  Testing.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Integrating Algorithms and Coding into the Mathematics Classroom
Chapter 1 Introduction 2nd Semester H
Program design Program Design Process has 2 phases:
Basics of Computer A Computer is Electronic device that can
Programming Languages
CSCI-235 Micro-Computer Applications
Computer Programming.
1-1 Logic and Syntax A computer program is a solution to a problem.
ALGORITHMS AND FLOWCHARTS
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Introduction to Algorithm – part 1
2.0 Problem Solving PROGRAM DESIGN
Introduction to Computer Programming
Programming Fundamentals
Control Structure Senior Lecturer
Lecture 2: Logical Problems with Choices
Unit# 9: Computer Program Development
Computer Programming LAB 1 Tejalal Choudhary Asst. Prof, CSE Dept.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Program Design Introduction to Computer Programming By:
Use of Mathematics using Technology (Maltlab)
Structured Program
Programming Fundamentals (750113) Ch1. Problem Solving
1) C program development 2) Selection structure
Chapter 2- Visual Basic Schneider
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Understanding Problems and how to Solve them by using Computers
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals (750113) Ch1. Problem Solving
Introduction to Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 2: Input, Processing, and Output
Basic Concepts of Algorithm
WJEC GCSE Computer Science
Presentation transcript:

BASIC PROGRAMMING FOR DATA ANALYSIS Dr. D. Dutta Roy Psychology Research Unit Indian Statistical Institute 203, B.T. Road Kolkata- 700108

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in CONTENTS Introduction: Definition, Types of Programming languages, Characteristics of good algorithm, Flowchart, Programming structure , Data analysis Data entry: File handling, reading and printing data, Array, Operators, Commands, Data entry, Statements, Adv.functions Data computation :Max score, result reporting 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in What is BASIC ? BASIC is an useful programming languages for data entry, data analysis and reporting the result. In programming, there are three languages: Machine level/low level (High state and low state or 1 and 0) and higher level languages. BASIC is a higher level language. BASIC means “ Beginner’s All Purpose Symbolic Instructions Code. Computer does not understand the higher level language so higher level language is converted to machine language. Between these two languages, assembly level language exists. It involves a set mnemonic codes. BASIC is simple and easy-to-learn language, particularly suitable for the non-specialist users. 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in What is Programming ? Programming is a set of commands or statements given to the computer in some computer language. These commands will be executed by the computer in a particular sequence. The list of commands given to the computer for solving a problem is called computer program.Any program written in high level language has to be translated into machine language before it is executed by the computer. This can be achieved with the help of translator programs - compilers (translating entire program and executing the program)and interpreters (translating each step and executing it). BASIC programs are normally interpreted not compiled. 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Algorithms Algorithm is a step-by-step procedure for solving a given problem. The characteristics of good algorithm are: They are simple but offer powerful and general solutions They are well documented to be used and easily understood by others They can be modified easily They give correct solutions They save computer time and memory space. They can be used as sub-procedures for other problems. 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Flow chart Flow charting is a diagrammatic representation of the problem solving process, in which decision steps are laid out in logical order. 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Operators 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Programming Structure Array creation Opening the input,output,append file Input/read data Analysis of data as per programming flow Displaying the output through file or through display unit as per user requirement End 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in ARRAY Array is used to store a large amount of data temporarily to different variables. There are two types of array: One dimensional array and two dimensional array. Syntax of one dimensional array Dim <arrayname> (max.data number) Dim Data (10) Syntax of Two dimensional array Dim <arrayname> (max.row, max.col.) Dim Data (10,5) 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Opening and Closing Files Input and Output statement 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

BASIC STATEMENT COMMANDS 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in TRANSFER STATEMENT GOTO <LINE NO.> GOSUB <LINE NO.> . RETURN 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Conditional statement(IF-THEN) IF-THEN-ELSE IF condition 1 THEN statement block 1 ELSE IF condition 2 THEN statement block 2 ELSE statement block n ENDIF 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Conditional statement(ON GOTO) ON EXPRESSION% GOTO LINE LIST. ON EXPRESSION% GOSUB LINE LIST. 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Conditional statement(SELECT) Co Select case <variable name> case is >= 1 statement block1 case 2 to 4 statement block2 case 1 statement block 3 end select 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Flow of BASIC program There are three types of flow in writing the program: Sequential flow(working instructions sequentially) Repetitive flow(doing same job repeatedly) Conditional repetitive flow(Flow depends upon satisfaction of condition) 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Data analysis There are three phases of data analysis: Data entry: data coding and feeding to computer, data tabulation and verification Data analysis: selection of useful measurement techniques and writing program Display of results: Displaying the data following user’s specification 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in DATA ENTRY AND CODING CLS REM This program is for entering the data and coding the variables OPEN "c:\windows\desktop\test.dat" FOR APPEND AS #1 LOC1 = 1 LOC2 = 2 10 INPUT "NAME OF STUDENTS ", NAME$ IF NAME$ = "0" THEN GOTO 100 INPUT "AGE ", AGE INPUT "LOCALITY (TYPE U FOR URBAN AND R FOR RURAL) ", LOC$ INPUT "MATHEMATICS EXAM. SCORE ", MATH IF LOC$ = "U" THEN WRITE #1, NAME$, AGE, LOC1, MATH IF LOC$ = "R" THEN WRITE #1, NAME$, AGE, LOC2, MATH GOTO 10 100 END 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Advance Functions 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in Matrix Manipulation A matrix is a rectangular array of numbers. In matrix algebra, the array is considered to be a single unit rather than collection of individual entries, and is operated upon as a unit. For calculation of two matrices, there should be the same number of rows and columns. A = 105 63 5 218 80 2 220 76 1 84 102 4 B = 240 121 1 302 28 0 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in

Addition of two matrices REM program to add matrices of two sets of data DIM a(3, 3), b(3, 3), c(3, 3) n = 3: m = 3 FOR i = 1 TO n FOR j = 1 TO m READ a(i, j) DATA 105,63,5,218,80,2,220,76,1 PRINT a(i, j) NEXT j NEXT i PRINT "=========================================" FOR k = 1 TO n FOR l = 1 TO m READ b(k, l) DATA 84,102,4,240,121,1,302,28,0 PRINT b(k, l) NEXT l NEXT k FOR mr = 1 TO n FOR mc = 1 TO m c(mr, mc) = a(mr, mc) + b(mr, mc) NEXT mc NEXT mr PRINT”+++++++++++++++++++++++++” FOR g = 1 TO n FOR h = 1 TO m PRINT c(g, h) NEXT h NEXT g 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in