Download presentation
Presentation is loading. Please wait.
1
BASIC PROGRAMMING FOR DATA ANALYSIS
Dr. D. Dutta Roy Psychology Research Unit Indian Statistical Institute 203, B.T. Road Kolkata
2
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,
3
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,
4
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,
5
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,
6
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,
7
Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in
Operators 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute,
8
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,
9
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,
10
Opening and Closing Files Input and Output statement
2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute,
11
BASIC STATEMENT COMMANDS
2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute,
12
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,
13
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,
14
Conditional statement(ON GOTO)
ON EXPRESSION% GOTO LINE LIST. ON EXPRESSION% GOSUB LINE LIST. 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute,
15
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,
16
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,
17
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,
18
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,
19
Dr. D. Dutta Roy, Indian Statistical Institute, ddroy@isical.ac.in
Advance Functions 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute,
20
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 = B = 2:55 AM Dr. D. Dutta Roy, Indian Statistical Institute,
21
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,
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.