Programming with Mathematica

Size: px
Start display at page:

Download "Programming with Mathematica"

Transcription

1 1 Programming with Mathematica Introductiontoprogramming Gettingstarted Gettinghelp Notesandfurtherreading Mathematica is a large system used across an astonishing array of disciplines physics, bioinformatics, geo-science, linguistics, network analysis, optics, risk management, software engineering, and many more. It integrates tools for importing, analyzing, simulating, visualizing, reporting, and connecting to other programs. Underlying all of these tools is a modern programming language with which you can extend the things you can do with Mathematica almost limitlessly. This book focuses on the programming language, but before we dive into details of syntax and structure, it will be helpful to look at some of the essential elements of actual programs to give you a better sense of what it means to program with Mathematica. So, to start, let us walk through the creation of a short program so you can see how a Mathematica programmer might solve a problem. We will not attempt to write the most efcient or shortest code here, but will instead concentrate on the process of programming things like rewording the problem, nding the right tools and approach, and testing your program. Hopefully, this prelude will give you a better sense of the breadth and depth of the Mathematica language and help you answer the question, Why use Mathematica to write programs? The second aim of this chapter is to help you become familiar with the Mathematica environment, showing you how to get started, how to work with the interface, documentation, and programming tools, and how to start putting them together to do interesting things. The basic syntax used by Mathematica is introduced, including functions and lists and several alternate syntaxes that you can use to input expressions. This is followed by information on how to get help when you get stuck or have trouble understanding an error that has occurred. If you are already familiar with these aspects of Mathematica, feel free to skim or skip these topics and return to them when the need arises.

2 2 Programming with Mathematica 1.1 Introduction1to1programming Computer 1programs 1are 1detailed 1and 1explicit 1descriptions 1of 1the 1steps 1to 1take 1to 1accomplish 1a specic 1task. 1The 1key 1is 1converting 1the 1original 1statement 1of 1the 1problem 1from 1something 1you might 1describe 1to 1a 1colleague 1in 1your 1native 1natural 1language 1into 1something 1that 1a 1computer 1can understand 1and 1operate 1on. 1As 1an 1example, 1suppose 1you 1want 1to 1write 1a 1program 1for 1your 1home s programmable1thermostat1to1control1the1temperature1in1your1house.1a1description1such1as1 turn1on the 1heat 1when 1it 1is 1cold 1and 1turn 1on 1the 1air 1conditioner 1when 1it 1is 1hot 1may 1be 1entirely 1understandable1to1the1humans1in1your1household,1but1will1be1of1little1help1in1communicating1with1the1thermostat. 1Instead, 1imagine 1formulating 1the 1problem 1as 1follows: 1if 1the 1ambient 1temperature 1drops 1below 17 c, 1turn 1on 1the 1heater 1until 1the 1ambient 1temperature 1reaches 122 c; 1if 1the 1temperature 1rises 1above 29 c,1turn1on1the1air1conditioner1until1the1temperature1drops1below124 c.1with1this1formulation1you have1enough1to1translate1those1instructions1into1a1program. Let s 1take 1this 1thought 1experiment 1one 1step 1further. 1What 1if 1you 1are 1away 1at 1work 1or 1school 1and a1door1in1your1house1blew1open1causing1the1heater1to1stay1on1in1an1attempt1to1warm1the1house1while cold 1air 1rushes 1in. 1Although 1this 1scenario 1is 1atypical, 1your 1program 1could 1include 1a 1conditional check1that1turns1the1unit1off1for1one1hour1say,1if1it1has1been1on1continuously1for1over1two1hours. The 1task 1that 1we 1commonly 1think 1of 1as 1 programming 1is 1the 1set 1of 1steps 1that 1take 1a 1description like1the1explicit1formulation1above1for1the1thermostat1and1actually1write1code1in1a1language1that1can be 1executed 1on 1a 1processor 1on 1your 1computer 1or 1on 1the 1thermostat 1itself 1(with 1an 1embedded application).1we1will1pick1it1up1from1here1with1an1example1that1walks1through1the1steps1of1creating, testing,1and1rening1a1program.1using1a1problem1that1is1simple1to1describe1and1does1not1require1a1lot of1sophisticated1programming1will1help1to1better1focus1on1these1 meta 1steps. Your1rst1Mathematica1program We 1will 1create 1a 1small 1program 1to 1solve 1a 1specic 1problem 1 1nding 1and 1counting 1palindromic numbers. 1The 1process 1involves 1stating 1and 1then 1reformulating 1the 1problem, 1implementation, checking 1typical 1and 1atypical 1input, 1analyzing 1and 1improving 1efciency, 1and 1performing 1a 1postmortem. 1There 1are 1more 1aspects 1that 1will 1be 1discussed 1throughout 1this 1book, 1such 1as 1localization, options, 1argument 1checking, 1and 1documentation, 1but 1at 1this 1stage 1we 1will 1keep 1this 1initial 1problem simple.1you1are1not1expected1to1be1familiar1with1all1aspects1of1the1program1at1this1point;1instead,1try to1focus1on1the1process1here,1rather1than1the1details. As 1you 1read 1through 1the 1problem, 1enter 1each 1of 1the 1inputs 1in 1a 1Mathematica 1notebook 1exactly 1as they 1appear 1here, 1being 1careful 1about 1the 1syntax. 1When 1you 1have 1completed 1each 1input, 1press +1on1your1keyboard1to1evaluate,1then1go1on1to1the1next1input1(see1Section11.21for1details). Problem Find 1all 1palindromic 1numbers 1less 1than 1one 1thousand, 1then 1determine 1how 1many 1palindromes1there1are1that1are1less1than1one1million.

3 1.1 Introduction1to1programming 3 Reformulate1the1problem A1number1is1a1palindrome1if1it1is1equal1to1the1number1formed1by1reversing1its digits. 1For 1example, is 1a 1palindrome, is 1not. 1The 1problem 1is 1to 1create 1a 1function 1that checks 1if 1a 1number 1is 1palindromic 1(returns 1True 1if 1it 1is, 1False 1otherwise); 1then, 1from 1a 1list 1of 1the numbers1one1through1n,1nd1all1those1that1pass1this1palindrome1test. We1have1restated1the1problem1with1an1eye1toward1creating1explicit1instructions.1The1ability1to1do this 1comes 1from 1a 1knowledge 1of 1the 1constructs 1and 1paradigms 1present 1in 1our 1language, 1something that1is1learned1over1time1and1experience1with1that1language. Implementation Given 1an 1integer, 1rst 1we 1will 1get 1a 1list 1of 1its 1digits, 1then 1reverse 1that 1list, 1and 1nally check1that1the1reversed1list1is1identical1to1the1original1list.1start1by1getting1the1digits1of1a1number. In[1]:= IntegerDigits[ ] Out[1]= {1, 5, 5, 2, 5, 5, 1} Function 1names 1like 1IntegerDigits 1are 1spelled 1out 1in 1full, 1capitalizing 1the 1rst 1letter 1of 1each complete1word.1arguments1to1functions, in1this1example,1are1enclosed1in1square1brackets. Next,1reverse1the1digits. In[2]:= Reverse[IntegerDigits[ ]] Out[2]= {1, 5, 5, 2, 5, 5, 1} Check1if1the1list1of1digits1is1equal1to1the1list1of1reversed1digits. In[3]:= IntegerDigits[ ] ==Reverse[IntegerDigits[ ]] Out[3]= True Turn1this1into1a1program/function1that1can1be1run/evaluated1for1any1input. In[4]:= PalindromeQ[n_] := IntegerDigits[n] == Reverse[IntegerDigits[n]] Check1a1few1numbers: In[5]:= PalindromeQ[ ] Out[5]= False In[6]:= PalindromeQ[ ] Out[6]= True Check1atypical1input Try1the1function1with1input1for1which1it1was1not1meant,1for1example,1a1symbol. In[7]:= Out[7]= PalindromeQ[f] True That 1is 1not 1handling 1bad 1input 1correctly. 1We 1should 1try 1to 1restrict 1the 1function 1to 1integer 1input (Section16.21discusses1the1framework1for1issuing1warning1messages1when1bad1input1is1given). In[8]:= Clear[PalindromeQ]; PalindromeQ[n_Integer] := IntegerDigits[n] == Reverse[IntegerDigits[n]]

4 4 Programming with Mathematica Check1a1few1bad1inputs: In[10]:= Out[10]= PalindromeQ[f] PalindromeQ[f] In[11]:= Out[11]= PalindromeQ[{a, b, c}] PalindromeQ[{a, b, c}] Solve 1original 1problem The 1original 1questions 1were: 1nd 1all 1palindromes 1below 1one 1thousand 1and determine1how1many1there1are1below1one1million. In[12]:= SelectRange10 3, PalindromeQ Out[12]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616, 626, 636, 646, 656, 666, 676, 686, 696, 707, 717, 727, 737, 747, 757, 767, 777, 787, 797, 808, 818, 828, 838, 848, 858, 868, 878, 888, 898, 909, 919, 929, 939, 949, 959, 969, 979, 989, 999} In[13]:= Out[13]= 1998 CountRange10 6, p_ /; PalindromeQ[p] Efciency How1fast1is1this1function1for1a1large1list1of1integers? In[14]:= Out[14]= AbsoluteTiming SelectRange10 6, PalindromeQ; { , Null} Not1too1bad,1but1perhaps1we1can1speed1things1up.1In1the1denition1of1PalindromeQ,1we1compute IntegerDigits[n] 1twice, 1once 1on 1each 1side 1of 1the 1equality 1check. 1Instead 1we 1can 1create 1a 1local variable 1digs 1and 1initialize 1it 1with 1the 1value 1of 1IntegerDigits[n], 1thus 1only 1doing 1that 1computation1once. In[15]:= In[16]:= In[17]:= Out[17]= Clear[PalindromeQ]; PalindromeQ[n_Integer] := With[{digs = IntegerDigits[n]}, digs == Reverse[digs] ] AbsoluteTiming SelectRange10 6, PalindromeQ; { , Null} That 1didn t 1help 1much 1 1probably 1introducing 1the 1scoping 1construct 1With 1negated 1any 1small gains 1from 1reducing 1the 1size 1of 1the 1computation. 1Another 1strategy 1might 1consider 1using 1strings

5 1.1 Introduction1to1programming 5 which, 1we 1know 1from 1experience, 1can 1be 1very 1fast 1to 1work 1with. 1We 1will 1save 1this 1approach 1for Chapter171where1we1discuss1strings1and1compare1implementations1using1lists1versus1strings. Actually1this1problem1will1parallelize1well1as1the1list1of1numbers1to1be1checked1can1be1distributed across 1kernels 1and 1processors. 1Any 1speed 1improvement 1will 1be 1tied 1to 1the 1number 1of 1processors available1to1run1the1kernels. In[18]:= Out[18]= LaunchKernels[] {KernelObject[1, local], KernelObject[2, local], KernelObject[3, local], KernelObject[4, local]} In[19]:= Out[19]= In[20]:= Out[20]= DistributeDefinitions[PalindromeQ] {PalindromeQ} AbsoluteTiming ParallelizeSelectRange10 6, PalindromeQ; { , Null} Postscript As 1you 1work 1through 1this 1example 1note 1that 1the 1notebook 1in 1which 1the 1code 1was 1developed 1and 1tested 1becomes 1a 1documentation 1of 1sorts 1with 1comments 1in 1text 1cells 1interspersed 1here and1there1to1help1whoever1looks1at1the1code1to1understand1your1thinking1(including1yourself1several months 1or 1years 1later). 1In 1other 1words, 1the 1notebook 1interface 1is 1your 1development 1environment. You 1could 1also 1bundle 1up 1your 1code 1into 1a 1formal 1package 1 1a 1platform-independent 1text 1le containing1mathematica1commands1 1that1could1be1loaded1when1needed1(see1Chapter110). The1code1in1these1examples1uses1a1variety1of1programming1styles1and1constructs1that1may1be1new to1you.1it1is1entirely1forgivable1if1you1do1not1understand1them1at1this1point1 1that1is1what1this1book1is all1about!1by1the1time1you1have1worked1through1a1good1deal1of1the1book1you1should1be1comfortable solving 1problems 1using 1the 1basic 1principles 1of 1programming 1 1making 1assignments, 1dening 1rules, using1conditionals,1recursion,1and1iteration. Programming1paradigms As 1you 1start 1to 1write 1programs 1in 1Mathematica, 1it 1is 1natural 1to 1ask, 1 How 1does 1it 1compare 1with programming 1in 1other 1languages? 1To 1start, 1there 1are 1certain 1details 1shared 1by 1all 1programming languages1and1environments.1in1any1language,1there1is1a1nite1collection1of1objects1that1must1be1put together 1in 1a 1specic 1order 1to 1make 1statements 1that 1are 1valid 1in 1that 1language. 1In 1natural 1languages, say1english,1those1objects1are1the1alphabet,1punctuation1symbols,1spaces,1and1so1on.1the1rules1of1the language 1describe 1what 1are 1valid 1statements 1in 1that 1language. 1In 1computer 1languages, 1those 1statements 1are 1used 1to 1communicate 1instructions 1to 1a 1computer, 1say 1to 1add 1two 1integers, 1or 1to 1print 1a string1to1the1screen,1or1to1iterate1a1function1until1a1condition1is1met.1 The 1chief 1way 1in 1which 1languages 1differ 1is 1in 1the 1style 1of 1programming 1that 1each 1language 1uses. Early 1programming 1languages, 1such 1as 1Fortran 1and 1C 1(and 1a 1bit 1later 1Perl, 1Python, 1and 1many

6 6 Programming with Mathematica others), 1use 1what 1is 1referred 1to 1as 1an 1imperative 1style 1of 1programming. 1This 1is 1one 1in 1which 1a 1specic sequence 1of 1operations 1are 1explicitly 1given 1and 1the 1ow 1of 1execution 1is 1controlled 1by 1the 1programmer.1In1other1words,1the1instructions1describe1how1to1perform1each1step.1 Declarative 1languages, 1in 1contrast, 1describe 1the 1desired 1result 1instead 1of 1focusing 1on 1the 1underlying 1machine 1instructions 1to 1get 1there. 1That 1is, 1they 1describe 1what 1to 1do, 1rather 1than 1how. 1Lisp, Scheme, 1Haskell, 1and 1Mathematica 1are 1mostly 1declarative 1languages, 1although 1each 1allows 1an imperative-style1of1programming1(particularly1procedural)1to1be1used1as1well. Further1distinguishing1languages1from1one1another1are1the1steps1the1programmer1takes1to1try1out their 1programs. 1In 1most 1traditional 1languages 1such 1as 1Fortran, 1C, 1and 1Java, 1you 1start 1by 1writing code 1in 1an 1editor 1using 1the 1constructs 1of 1the 1language. 1In 1Java, 1you 1might 1write 1the 1following source1code1in1an1editor: public class HelloWorld { public static void main (String[] args){ System.out.println ("Hello, World"); } } For1a1similar1program1in1C,1you1would1type: main () { printf ("hello, world"); } After 1saving 1your 1code 1in 1an 1appropriately 1named 1le, 1you 1then 1run 1it 1through 1a 1compiler 1to create 1an 1executable 1le 1that 1can 1be 1run 1on 1your 1computer. 1If 1there 1is 1an 1error 1somewhere 1in 1your program, 1you 1go 1back 1to 1your 1source 1code 1and, 1perhaps 1with 1the 1aid 1of 1a 1debugger, 1you 1nd 1and correct1any1errors1and1then1recompile1your1program1and1execute1it1again. But 1there 1is 1another 1way. 1Some 1languages, 1such 1as 1Lisp, 1Perl, 1Python, 1Ruby, 1and 1Mathematica, are 1referred 1to 1as 1interpreted 1languages. 1What 1this 1means 1is 1that 1you 1use 1them 1in 1an 1interactive 1mode: you 1type 1in 1a 1command, 1evaluate 1it 1in 1place, 1and 1the 1result 1is 1returned. 1The 1environment 1in 1which you 1type 1in 1the 1command 1and 1see 1the 1results 1is 1the 1same; 1in 1Mathematica, 1that 1environment 1is 1the notebook. In1Perl,1the1 Hello1World 1program1is1simply: print "Hello World!\n"; In1Mathematica,1you1type1in1and1then1evaluate1the1following: In[21]:= Print["Hello world"] Hello world The1advantage1of1interpreted1languages1is1that1you1entirely1avoid1the1compile/run/debug1cycle1of other 1languages. 1In 1addition, 1these 1so-called 1high-level 1interpreted 1languages 1contain 1functions 1for performing 1many 1tasks 1that 1you 1would 1typically 1have 1to 1implement 1in 1a 1lower-level 1language 1(if you 1are 1a 1C 1programmer, 1compare 1Reverse[lis] 1in 1Mathematica 1with 1a 1C 1program 1to 1do 1the 1same

7 1.1 Introduction1to1programming 7 thing). 1This 1saves 1you 1time 1and 1lets 1you 1focus 1more 1on 1the 1problem 1at 1hand 1and 1less 1on 1the 1intricacies1of1memory1management,1libraries,1and1registers1say. In1the1old1days,1the1advantages1of1compiled1languages1were1speed1and1access1to1low-level1aspects of 1your 1computer. 1But 1with 1advances 1in 1hardware, 1these 1seeming 1advantages 1are 1much 1less 1clear. 1If a1program1runs1a1few1tenths1of1a1second1faster1but1takes1many1more1minutes1to1create,1your1productivity1gains1start1to1evaporate1pretty1quickly. Creating1programs In 1any 1language, 1the 1creation 1of 1computer 1programs 1involves 1many 1different 1tasks. 1For 1our 1purposes1here1it1is1useful1to1distinguish1two1broad1categories:1programming1and1software1development.1 Programming1involves: Analysis1of1the1problem.1This1includes1understanding1precisely1what1is1being1asked1and1what1the1 answers1will1look1like. Restatement1of1the1problem.1Phrasing1the1problem1in1a1way1that1is1closer1to1how1you1will1actually1 write1the1program;1creating1pseudo-code. Formulating1a1plan1of1attack.1With1what1type1of1data1can1you1prototype1the1problem?1Is1the1 problem1one1that1can1be1solved1using1list1manipulation?1should1you1use1string1functions?1 Will1the1computation1require1extraordinary1resources? Implementation.1Translating1the1problem1into1code;1modularization;1if1using1an1interactive1 language,1trying1out1pieces1as1you1go. Software1development1includes: Verication1of1correctness.1Checking1solutions1for1many1types1of1input;1comparing1with1known1 solutions;1using1different1algorithms1to1make1comparisons. Debugging.1Finding1and1correcting1errors1 1from1bad1syntax1or1from1incorrect1algorithms. Robustness.1Checking1atypical1input1that1includes1special1cases,1bad1input,1and1generally1input1 that1your1program1was1not1designed1for. Performance1and1efciency.1Identifying1bottlenecks1(possibly1through1proling)1to1improve1 memory1usage1and1reduce1compute1time,1network1bandwidth. Documentation.1Comments1and1notes1about1why1a1specic1function1or1approach1was1used1at1a1 certain1step;1documenting1lightly1as1you1program1and1then1adding1more1substantial1 information1later. User1interface.1What1does1the1user1need1to1know1to1understand1how1to1use1your1program?1Does1 it1behave1like1built-in1functions1or1will1the1user1need1to1learn1a1new1interface1element. Portability.1Does1your1program1work1on1different1platforms,1environments?1Do1you1need1to1 compile1for1different1operating1systems?1(your1mathematica1programs1will1run1unchanged1on1 any1platform1that1runs1mathematica.)

8 8 Programming with Mathematica Code maintenance. Periodic checks that your code runs in the latest version of your programming language, on the latest operating system, etc. Not every program you create will include all of the above pieces, and the order in which you implement them is not so well-dened and discrete as stated here. For example, the PalindromeQ program created in the previous section did not include formal documentation outside of comments in the notebook itself. Smaller programs written to solve a basic problem, or programs that you have no intention of sharing with a colleague, student, or client, may not need some of the niceties (such as user interface elements) that another program would have. But the availability of these programming tools and constructs makes Mathematica a good choice for both small programs and large-scale applications that will be used by others. This book is designed to give you a good sense of this breadth and depth and to provide a foundational set of tools to use in your Mathematica programming. 1.2 Getting started Let us now turn to some of the basics needed to start using Mathematica. If you are not familiar with Mathematica, it would be helpful to try out the examples in this section before going further. These examples should give you a sense of what it means to enter, evaluate, and work with some simple computations. If you are already familiar with Mathematica, feel free to skim this section lightly. Starting and running Mathematica After launching Mathematica, parts of it will load into memory and soon a blank window will appear on the screen. This window, called a notebook, is the visual interface to Mathematica. Whenablanknotebookrstappearsonthescreen,eitherfromjuststartingMathematicaorfrom selectingnewinthefilemenu,youcanstarttypingimmediately.forexample,typen[pi,200] and then press + (hold down the Shift key while pressing the Enter key) to evaluate the expression.mathematicawillevaluatetheresultandprintthe200-decimal-digitapproximationto. When you evaluate an expression in a notebook, Mathematica automatically adds input and output prompts after you evaluate your input. In the example notebook at the top of the next page,

9 1.2 Getting started 9 these are denoted In[1]:= and Out[1]=. These prompts can be thought of as markers (or labels) that you can refer to during your Mathematica session. New input can be entered whenever there is a horizontal line that runs across the width of the notebook. If one is not present where you wish to place an input cell, move the cursor up and down until it changes to a horizontal bar and then click the mouse once. A horizontal line should appear across the width of the window. You can immediately start typing and an input cell will be created. Mathematical expressions can be entered in a traditional-looking two-dimensional format using either palettes for quick entry of template expressions, or keyboard equivalents. For example, the following expression can be entered by using the Basic Math Assistant palette (under the Palettes menu), or through a series of keystrokes as described in the tutorial Entering Two-Dimensional Input in the Wolfram Language Documentation Center (WLDC). In[1]:= Out[1]= To refer to the result of the previous calculation, use the symbol %. In[2]:= %+1 Out[2]= To refer to the result of any earlier calculation, use its Out i label or, equivalently, % i. In[3]:= Out[1] Out[3]= In[4]:= (%1)2 90 Out[4]= 1024 Mathematical expressions Mathematical expressions can be entered in a linear syntax using arithmetic operators common to almost all computer languages. In[5]:= 39 / 13 Out[5]= 3 Enter this expression in the traditional form by typing 39, /, then 13.

10 10 Programming with Mathematica In[6]:= Out[6]= 3 The1caret1(^)1is1used1for1exponentiation. In[7]:= 2^5 Out[7]= 32 To1enter1this1expression1in1a1more1traditional1typeset1form,1type12,1^,1and1then15. In[8]:= 2 5 Out[8]= 32 Multiplication 1can 1be 1indicated 1by 1putting 1a 1space 1between 1the 1two 1factors, 1as 1in 1mathematical notation. 1Mathematica 1will 1automatically 1display 1the 1traditional 1multiplication 1sign, 1, 1between 1two numbers.1the1asterisk1(*)1is1also1used1for1that1purpose,1as1is1traditional1in1most1computer1languages. In[9]:= 2 5 Out[9]= 10 In[10]:= 2 * 5 Out[10]= 10 Operations 1are 1given 1the 1same 1precedence 1as 1in 1mathematics. 1In 1particular, 1multiplication 1and division1have1a1higher1precedence1than1addition1and1subtraction: equals1231and1not135. In[11]:= Out[11]= 23 You1can1enter1typeset1expressions1in1several1different1ways:1directly1from1the1keyboard1as1we1did above, 1using 1a 1long 1(functional) 1form, 1or 1via 1palettes 1available 1from 1the 1Palettes 1menu. 1Table 11.1 shows1some1of1the1more1commonly1used1typeset1expressions1and1how1they1are1entered1through1the keyboard.1try1to1become1comfortable1entering1these1inputs1so1that1you1can1easily1enter1the1kinds1of expressions1used1in1this1book. Table11.1. Entering1typeset1expressions Display form Long (functional) form Keystrokes x 2 Superscript[x,2] x, +6, 2 x i Subscript[x,i] x, +_, i x y FractionBox[x,2] x, +/, y x SqrtBox[x] +2, x x y GreaterEqual[x,2] x,, >=,, y

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form

More information

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. Plan for the rest of the semester: Programming We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems. We saw earlier that computers

More information

Programming Languages 2nd edition Tucker and Noonan"

Programming Languages 2nd edition Tucker and Noonan Programming Languages 2nd edition Tucker and Noonan" " Chapter 1" Overview" " A good programming language is a conceptual universe for thinking about programming. " " " " " " " " " " " " "A. Perlis" "

More information

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

CPS122 Lecture: From Python to Java last revised January 4, Objectives: Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

STUDENT LESSON A1 Introduction to Object-Oriented Programming (OOP)

STUDENT LESSON A1 Introduction to Object-Oriented Programming (OOP) STUDENT LESSON A1 Introduction to Object-Oriented Programming (OOP) Java Curriculum for AP Computer Science, Student Lesson A1 1 STUDENT LESSON A1 Introduction to Object-Oriented Programming (OOP) INTRODUCTION:

More information

CS112 Lecture: Working with Numbers

CS112 Lecture: Working with Numbers CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations

More information

Table of Contents EVALUATION COPY

Table of Contents EVALUATION COPY Table of Contents Introduction... 1-2 A Brief History of Python... 1-3 Python Versions... 1-4 Installing Python... 1-5 Environment Variables... 1-6 Executing Python from the Command Line... 1-7 IDLE...

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

11 Data Structures Foundations of Computer Science Cengage Learning

11 Data Structures Foundations of Computer Science Cengage Learning 11 Data Structures 11.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define a data structure. Define an array as a data structure

More information

St. Edmund Preparatory High School Brooklyn, NY

St. Edmund Preparatory High School Brooklyn, NY AP Computer Science Mr. A. Pinnavaia Summer Assignment St. Edmund Preparatory High School Name: I know it has been about 7 months since you last thought about programming. It s ok. I wouldn t want to think

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

Curriculum Map Grade(s): Subject: AP Computer Science

Curriculum Map Grade(s): Subject: AP Computer Science Curriculum Map Grade(s): 11-12 Subject: AP Computer Science (Semester 1 - Weeks 1-18) Unit / Weeks Content Skills Assessments Standards Lesson 1 - Background Chapter 1 of Textbook (Weeks 1-3) - 1.1 History

More information

How to approach a computational problem

How to approach a computational problem How to approach a computational problem A lot of people find computer programming difficult, especially when they first get started with it. Sometimes the problems are problems specifically related to

More information

Full file at

Full file at Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional

More information

EXCEL BASICS: MICROSOFT OFFICE 2010

EXCEL BASICS: MICROSOFT OFFICE 2010 EXCEL BASICS: MICROSOFT OFFICE 2010 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT EXCEL PAGE 03 Opening Microsoft Excel Microsoft Excel Features Keyboard Review Pointer Shapes

More information

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables

More information

Computer Principles and Components 1

Computer Principles and Components 1 Computer Principles and Components 1 Course Map This module provides an overview of the hardware and software environment being used throughout the course. Introduction Computer Principles and Components

More information

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science Chapter 9 Introduction to High-Level Language Programming INVITATION TO Computer Science 1 Objectives After studying this chapter, students will be able to: Explain the advantages of high-level programming

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

Section 2.2 Your First Program in Java: Printing a Line of Text

Section 2.2 Your First Program in Java: Printing a Line of Text Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two

More information

CSI Lab 02. Tuesday, January 21st

CSI Lab 02. Tuesday, January 21st CSI Lab 02 Tuesday, January 21st Objectives: Explore some basic functionality of python Introduction Last week we talked about the fact that a computer is, among other things, a tool to perform high speed

More information

EXCEL BASICS: MICROSOFT OFFICE 2007

EXCEL BASICS: MICROSOFT OFFICE 2007 EXCEL BASICS: MICROSOFT OFFICE 2007 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT EXCEL PAGE 03 Opening Microsoft Excel Microsoft Excel Features Keyboard Review Pointer Shapes

More information

Introduction to Software Development (ISD) David Weston and Igor Razgon

Introduction to Software Development (ISD) David Weston and Igor Razgon Introduction to Software Development (ISD) David Weston and Igor Razgon Autumn term 2013 Course book The primary book supporting the ISD module is: Java for Everyone, by Cay Horstmann, 2nd Edition, Wiley,

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013

CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013 CS252 Advanced Programming Language Principles Prof. Tom Austin San José State University Fall 2013 What are some programming languages? Why are there so many? Different domains Mobile devices (Objective

More information

STEPHEN WOLFRAM MATHEMATICADO. Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS

STEPHEN WOLFRAM MATHEMATICADO. Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS STEPHEN WOLFRAM MATHEMATICADO OO Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS Table of Contents XXI a section new for Version 3 a section new for Version 4 a section substantially modified for

More information

Programming. Syntax and Semantics

Programming. Syntax and Semantics Programming For the next ten weeks you will learn basic programming principles There is much more to programming than knowing a programming language When programming you need to use a tool, in this case

More information

Programming Lecture 3

Programming Lecture 3 Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements

More information

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

2 Getting Started. Getting Started (v1.8.6) 3/5/2007 2 Getting Started Java will be used in the examples in this section; however, the information applies to all supported languages for which you have installed a compiler (e.g., Ada, C, C++, Java) unless

More information

Simple Java Programming Constructs 4

Simple Java Programming Constructs 4 Simple Java Programming Constructs 4 Course Map In this module you will learn the basic Java programming constructs, the if and while statements. Introduction Computer Principles and Components Software

More information

Getting Started with Mathematica

Getting Started with Mathematica G563 Quantitative Paleontology Department of Geological Sciences P. David Polly Getting Started with Mathematica Mathematica has a unique interface that takes a while to get used to. You open to a blank

More information

Programmiersprachen (Programming Languages)

Programmiersprachen (Programming Languages) 2016-05-13 Preface Programmiersprachen (Programming Languages) coordinates: lecturer: web: usable for: requirements: No. 185.208, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/ps.html

More information

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1 Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

What is a programming language?

What is a programming language? Overview Introduction Motivation Why study programming languages? Some key concepts What is a programming language? What is a programming language?...there is no agreement on what a programming language

More information

Section 2.2 Your First Program in Java: Printing a Line of Text

Section 2.2 Your First Program in Java: Printing a Line of Text Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two

More information

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6] 1 Lecture Overview Types 1. Type systems 2. How to think about types 3. The classification of types 4. Type equivalence structural equivalence name equivalence 5. Type compatibility 6. Type inference [Scott,

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

ü 1.1 Getting Started

ü 1.1 Getting Started Chapter 1 Introduction Welcome to Mathematica! This tutorial manual is intended as a supplement to Rogawski's Calculus textbook and aimed at students looking to quickly learn Mathematica through examples.

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Objectives. Structure. Munster Programming Training

Objectives. Structure. Munster Programming Training 1 Munster Programming Training Objectives 1. To give a short and basic introduction to computer programming, web design, web animation and video production. 2. To foster interest in computers by encouraging

More information

CS 31: Intro to Systems Binary Arithmetic. Martin Gagné Swarthmore College January 24, 2016

CS 31: Intro to Systems Binary Arithmetic. Martin Gagné Swarthmore College January 24, 2016 CS 31: Intro to Systems Binary Arithmetic Martin Gagné Swarthmore College January 24, 2016 Unsigned Integers Suppose we had one byte Can represent 2 8 (256) values If unsigned (strictly non-negative):

More information

MIDTERM EXAMINATION. CSE 130: Principles of Programming Languages. Professor Goguen. February 16, points total

MIDTERM EXAMINATION. CSE 130: Principles of Programming Languages. Professor Goguen. February 16, points total CSE 130, Winter 2006 MIDTERM EXAMINATION CSE 130: Principles of Programming Languages Professor Goguen February 16, 2006 100 points total Don t start the exam until you are told to. Turn off any cell phone

More information

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples Outline Introduction to Programming (in C++) Introduction Programming examples Algorithms, programming languages and computer programs Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer

More information

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007 Course Web Site http://www.nps.navy.mil/cs/facultypages/squire/cs2900 All course related materials will be posted

More information

Unit E Step-by-Step: Programming with Python

Unit E Step-by-Step: Programming with Python Unit E Step-by-Step: Programming with Python Computer Concepts 2016 ENHANCED EDITION 1 Unit Contents Section A: Hello World! Python Style Section B: The Wacky Word Game Section C: Build Your Own Calculator

More information

COMPUTER PROGRAMMING LOOPS

COMPUTER PROGRAMMING LOOPS COMPUTER PROGRAMMING LOOPS http://www.tutorialspoint.com/computer_programming/computer_programming_loops.htm Copyright tutorialspoint.com Let's consider a situation when you want to write five times. Here

More information

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 Natural Semantics Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 1 Natural deduction is an instance of first-order logic; that is, it is the formal

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

More information

COMP 110 Project 1 Programming Project Warm-Up Exercise

COMP 110 Project 1 Programming Project Warm-Up Exercise COMP 110 Project 1 Programming Project Warm-Up Exercise Creating Java Source Files Over the semester, several text editors will be suggested for students to try out. Initially, I suggest you use JGrasp,

More information

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15 Table of Contents 1 INTRODUCTION... 1 2 IF... 1 2.1 BOOLEAN EXPRESSIONS... 3 2.2 BLOCKS... 3 2.3 IF-ELSE... 4 2.4 NESTING... 5 3 SWITCH (SOMETIMES KNOWN AS CASE )... 6 3.1 A BIT ABOUT BREAK... 7 4 CONDITIONAL

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #06 Loops: Operators

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #06 Loops: Operators Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #06 Loops: Operators We have seen comparison operators, like less then, equal to, less than or equal. to and

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

Functional Programming and Haskell

Functional Programming and Haskell Functional Programming and Haskell Tim Dawborn University of Sydney, Australia School of Information Technologies Tim Dawborn Functional Programming and Haskell 1/22 What are Programming Paradigms? A programming

More information

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip.

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip. MAPLE Maple is a powerful and widely used mathematical software system designed by the Computer Science Department of the University of Waterloo. It can be used for a variety of tasks, such as solving

More information

CPS122 Lecture: From Python to Java

CPS122 Lecture: From Python to Java Objectives: CPS122 Lecture: From Python to Java last revised January 7, 2013 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.

More information

CSCE 120: Learning To Code

CSCE 120: Learning To Code CSCE 120: Learning To Code Manipulating Data I Introduction This module is designed to get you started working with data by understanding and using variables and data types in JavaScript. It will also

More information

Symbol Tables Symbol Table: In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is

More information

last time in cs recitations. computer commands. today s topics.

last time in cs recitations. computer commands. today s topics. last time in cs1007... recitations. course objectives policies academic integrity resources WEB PAGE: http://www.columbia.edu/ cs1007 NOTE CHANGES IN ASSESSMENT 5 EXTRA CREDIT POINTS ADDED sign up for

More information

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

More information

Ph3 Mathematica Homework: Week 1

Ph3 Mathematica Homework: Week 1 Ph3 Mathematica Homework: Week 1 Eric D. Black California Institute of Technology v1.1 1 Obtaining, installing, and starting Mathematica Exercise 1: If you don t already have Mathematica, download it and

More information

CS102 Unit 2. Sets and Mathematical Formalism Programming Languages and Simple Program Execution

CS102 Unit 2. Sets and Mathematical Formalism Programming Languages and Simple Program Execution 1 CS102 Unit 2 Sets and Mathematical Formalism Programming Languages and Simple Program Execution 2 Review Show how "Hi!\n" would be stored in the memory below Use decimal to represent each byte Remember

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

Modern Programming Languages. Lecture LISP Programming Language An Introduction

Modern Programming Languages. Lecture LISP Programming Language An Introduction Modern Programming Languages Lecture 18-21 LISP Programming Language An Introduction 72 Functional Programming Paradigm and LISP Functional programming is a style of programming that emphasizes the evaluation

More information

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented Course Goal CMSC 330: Organization of Programming Languages Introduction Learn how programming languages work Broaden your language horizons! Different programming languages! Different language features

More information

Full file at

Full file at Chapter 2 Introduction to Java Applications Section 2.1 Introduction ( none ) Section 2.2 First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler

More information

Modesto City Schools. Secondary Math I. Module 1 Extra Help & Examples. Compiled by: Rubalcava, Christina

Modesto City Schools. Secondary Math I. Module 1 Extra Help & Examples. Compiled by: Rubalcava, Christina Modesto City Schools Secondary Math I Module 1 Extra Help & Examples Compiled by: Rubalcava, Christina 1.1 Ready, Set, Go! Ready Topic: Recognizing a solution to an equation. The solution to an equation

More information

Introduction to JAVA

Introduction to JAVA Java A001 Hello World Let's study the entire program below: Introduction to JAVA // The "A001" class. import java.awt.*; public class A001 { public static void main (String[] args) { System.out.println("Hello

More information

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

MEAP Edition Manning Early Access Program Get Programming with Java Version 1 MEAP Edition Manning Early Access Program Get Programming with Java Version 1 Copyright 2018 Manning Publications For more information on this and other Manning titles go to www.manning.com welcome First,

More information

Variables and Data Representation

Variables and Data Representation You will recall that a computer program is a set of instructions that tell a computer how to transform a given set of input into a specific output. Any program, procedural, event driven or object oriented

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

More information

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want

More information

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker Computers in Engineering COMP 208 Computer Structure Michael A. Hawker Computer Structure We will briefly look at the structure of a modern computer That will help us understand some of the concepts that

More information

MathML Editor: The Basics *

MathML Editor: The Basics * OpenStax-CNX module: m26312 1 MathML Editor: The Basics * Natalie Weber This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract This module provides

More information

Array Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)

Array Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7) Array Basics: Outline Arrays (Savitch, Chapter 7) TOPICS Array Basics Arrays in Classes and Methods Programming with Arrays Searching and Sorting Arrays Multi-Dimensional Arrays Static Variables and Constants

More information

Introduction. chapter Functions

Introduction. chapter Functions chapter 1 Introduction In this chapter we set the stage for the rest of the book. We start by reviewing the notion of a function, then introduce the concept of functional programming, summarise the main

More information

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit ICOM 4015 Advanced Programming Laboratory Chapter 1 Introduction to Eclipse, Java and JUnit University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís 1 Introduction This

More information

Haskell 98 in short! CPSC 449 Principles of Programming Languages

Haskell 98 in short! CPSC 449 Principles of Programming Languages Haskell 98 in short! n Syntax and type inferencing similar to ML! n Strongly typed! n Allows for pattern matching in definitions! n Uses lazy evaluation" F definition of infinite lists possible! n Has

More information

CHAPTER 1 Introduction to Computers and Java

CHAPTER 1 Introduction to Computers and Java CHAPTER 1 Introduction to Computers and Java Copyright 2016 Pearson Education, Inc., Hoboken NJ Chapter Topics Chapter 1 discusses the following main topics: Why Program? Computer Systems: Hardware and

More information

Operating system. Hardware

Operating system. Hardware Chapter 1.2 System Software 1.2.(a) Operating Systems An operating system is a set of programs designed to run in the background on a computer system, giving an environment in which application software

More information

ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW

ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW Objectives: The goal of this exercise is to introduce the Laboratory Virtual Instrument Engineering Workbench, or LabVIEW software. LabVIEW is the primary software

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

Chapter 7. Expressions and Assignment Statements ISBN

Chapter 7. Expressions and Assignment Statements ISBN Chapter 7 Expressions and Assignment Statements ISBN 0-321-49362-1 Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions Short-Circuit

More information

Getting Started (1.8.7) 9/2/2009

Getting Started (1.8.7) 9/2/2009 2 Getting Started For the examples in this section, Microsoft Windows and Java will be used. However, much of the information applies to other operating systems and supported languages for which you have

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming About the Tutorial Haskell is a widely used purely functional language. Functional programming is based on mathematical functions. Besides Haskell, some of the other popular languages that follow Functional

More information

COP4020 Programming Assignment 1 - Spring 2011

COP4020 Programming Assignment 1 - Spring 2011 COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to

More information

CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS

CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS Computers process information and usually they need to process masses of information. In previous chapters we have studied programs that contain a few variables

More information

Programming Language Basics

Programming Language Basics Programming Language Basics Lecture Outline & Notes Overview 1. History & Background 2. Basic Program structure a. How an operating system runs a program i. Machine code ii. OS- specific commands to setup

More information

Formulas in Microsoft Excel

Formulas in Microsoft Excel Formulas in Microsoft Excel Formulas are the main reason for wanting to learn to use Excel. This monograph is intended as a quick reference to the basic concepts underlying the use of formulas. It is prepared

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information