You are on page 1of 59

Introduction to Coding

Agenda:
Understandhowcomputersworkandlearnbasiccomputer
programmingconcepts(e.g.,variables,syntaxetc.)

Gainanappreciationofthevariousprogramminglanguagesandstudy
whattheycando.

Developaresourcelistofcomputerprogrammingtutorialsandtools.

Becomeinspiredtolearnprogrammingbasicstohelpyouworksmarter
andmoreefficiently.
Is coding a cryptic visual of typed languages?

Or a process? Or both?
Computerprogramminghasareputationof
beingcrypticandtoocomplexforthe
averageperson;however,whenyouget
familiarwithbasicprogramminglogicyou
willseepatternseverywhere!
What is computer programming?
Asetofcommandsacomputerunderstandslikearecipe.

Computerprogramscanhelpcurediseases;drivecars;createvideo
games;makeanimatedmovies/graphics;buildwebsitesandapps;and
muchmore.

Basiccodingconceptsareusedbymosteveryprogramandmostevery
programmer.

Tolearnmorevisithttp://www.bfoit.org/itp/Programming.html
Why learn to code?
Whynot?
Learntheimportanceofclarity/brevityofexpression.
Beabletothinkandproblemsolvemoreaccurately.
Haveabetterunderstandingofhowtechnologyworks.
Createatoolthatcanmakeyourlifeandmanyothersliveseasier.
Read more at http://goo.gl/Hgy16A
Ithasoftenbeensaidthatapersondoesnotreallyunderstand
somethinguntilheteachesittosomeoneelse.Actuallyaperson
doesnotreallyunderstandsomethinguntilafterteachingittoa
computer,i.e.,expressitasanalgorithm.

DonaldKnuth,inAmerican Mathematical Monthly


Describeinnaturallanguagehowtomake

apeanutbutterandjellysandwich.
Some great resources to help you
learn to code
.com

Learn to code interactively, for free.


http://www.oeconsortium.org/
https://www.coursera.org/
https://www.codeavengers.com/
https://www.khanacademy.org
https://teamtreehouse.com/
https://www.codeschool.com/
http://coderdojo.com
Some Other Coding Resources
Lightbot isa programmingpuzzlegamethatgivestheuseraone-to-onerelationshipwithprogrammingconcepts.Tryittodayat
http://light-bot.com/!

Hopscotch:Coding for Kids isaniPadprogramminglanguage.Downloadittodayathttps://www.gethopscotch.com/.


Code.orgwantstobringComputerScienceclassestoeveryK-12school.Checkitoutathttp://code.org/andfindsomeexcellent
computerprogrammingtutorials.

Scratchhelpschildrencreatestories,games,animations,andalsoletsthemsharetheseprojectswithothersaroundtheworld.
Moreinfoathttp://scratch.mit.edu/.

www.scratchjr.orgisafreeiPadappthatbringscodingtostudentsasyoungasagefive.
www.kodable.comgiveschildrenopportunitiestoprograminordertosolvepuzzles.http://www.allcancode.comissimilar.

VisitMediumfora2minutereadlistingotherideasandresourcestohelpinspirechildrenandteenstocode.

ThereareseveralMOOCs(MassiveOpenOnlineCourse)andotherfreelyavailableresourcesthatoffercomputerprogramming
classes.Coursera,Udacity,andEdxaregreatexamples.Also,KhanAcademyhassomegreatresourcesforkidsandadultstoo!

AGooglesearchqueryforcomputer programming resources for kids limitedtothelastyearcanbefoundathttp://goo.gl/RaUups.


What is a programming language?
Aprogramminglanguageissetofrulesthatprovidesawayoftellinga
computer:
Whatoperationstoperform
Communicatinganalgorithm
Receivesaninputfromtheuserandgeneratesanoutput.
Aprogramminglanguageisasystemfordescribingacomputation(math)or
algorithms(logic)inamachine-readableandhuman-readableform.
Haswords,symbols,andgrammaticalrules(naturallanguage)
Grammaticalrules=Syntax
Eachlanguagehasadifferentsetofsyntaxrules
Hassemantics(meaning)

SlidecourtesyofBrianPichman
Tons of example code in the Arduino
IDE (Integrated Development
Environment)
Raspberry Pi (Python)
programming

Blinking LED code at: http://goo.gl/O3yozd


https://www. .org/downloads
Python Shell is where you enter
commands and/or lines of code.

At the prompt type: print(Hello, world!)


IDLE - Integrated DeveLopment
Environment)

# is a comment and the computer ignores it.


The second line asks the user to enter their name and remembers it as "name. This is a variable!
The third line is a print statement, which prints the stored name.
demos
1.

2.
A Few Basic Programming Components
(pretty much regardless of language)

Variables&Arrays
Operators
FlowControl
Functions

SlidecourtesyofBrianPichman
Variables & Arrays

Avariableisabucketthatholdsonepieceofinformation.Avariable
canchangevaluewhen
Specificconditionsaremet
Basedonuserinput
Examples(concept)
$string_myhomelibrary=MontgomeryLibrary;
$numeric_variable=100;
$myname=Brian;

SlidecourtesyofBrianPichman
Variables & Arrays

Anarrayisatypeofvariable(orbucket)thatholdsmanypiecesof
information.
Example(languagedoesntmatterhere;theconceptdoes):
$FavoriteCities=array(Orlando,Boulder,Miami)
$FavoriteCities[0]holdsOrlando
$FavoriteCities[1]holdsBoulder
$States=array(1=>Prime;FL=>Florida,CO=>Colorado)
$States[FL]holdsFlorida

SlidecourtesyofBrianPichman
Operators

Arithmetic
+,-,*,/(add,subtract,multiply,divide)

Assignment
=(assignthevalueof2tothevariablecalledv)
$v=2;

+=(Addthevalueof3tothevariablethatalreadyholds1)
$v+=3;//$anowholds5

SlidecourtesyofBrianPichman
Flow Control - Sequence
Readslikeabook,theinstructionsareexecutedinthesameorder
theywheregiven:
OPENthedoor
WALKinsidetheroom
SITonachair
PICKUPabook
READthebook.

SlidecourtesyofBrianPichman
Flow Control - Choice
IfThen
if(somethingistrue/conditionsaremet){
then dothis
}
IfThenElse
Else:XYZ
StartsthesameasIfThenbutallowsaresultifconditionisfalse
ElseIf
if(somethingistrue/conditionsaremet){
thendothis
}elseif(anothersomethingistrue/conditionsaremet){
thendothisinstead
}

SlidecourtesyofBrianPichman
Flow Control - Continual
Withcontinual,instructionsareexecutedbasedonvariables,commands,
outputs,etcastheyremaintrue

While(orrepeat)
while(somethingistrue){
dosomethinghere
}
for
for(somethingistrue){
dosomethinghere
}

SlidecourtesyofBrianPichman
Flow Control Putting It
Together
1) Sequence
Gotothelibrary
Checkoutabook
Readthebook
Returnthebook
2) Choice
Ifyouhavealibrarycard,youcancheckoutbooks.Otherwiseopenalibrarycardaccount.
3) Repeat
Continuetoreadthebooktilltherearenomorepages.

SlidecourtesyofBrianPichman
Functions
Afunctionistypeofprocedureorroutineandusuallyreturnsavalue.
Aprocedurepreformsanoperation,buttypicallydoesntprovideavalue.
Mostlanguageshavepre-builtorpre-definedfunctionsinitslibrary.
Forinstance,thedeletefunctionmeanstoremove.Youdonthaveto
codewhatremovedoes;onlywhattoremove.

Defining a function in Python


DEMO
RAPTOR is a flowchart-
based programming
environment.
Download it for free and get great handouts at http://
raptor.martincarlisle.com
Traditional Programming Languages
FORTRAN
FORmula TRANslation.
Developed at IBM in the mid-1950s.
First programming language
Designed for scientific and mathematical applications by
scientists and engineers.

COBOL
COmmon Business Oriented Language.
Developed in 1959.
Typically used for business applications.

SlidecourtesyofBrianPichman
Traditional Programming Languages
(contd.)
BASIC
Beginners All-purpose Symbolic Instruction Code.
Developed at Dartmouth College in mid 1960s.
Developed as a simple language for students to write programs
with which they could interact through terminals.
C
Developed by Bell Laboratories in the early 1970s.
Provides control and efficiency of assembly language
Often used for system programs.
UNIX is written in C.

SlidecourtesyofBrianPichman
Object-Oriented Programming
Languages
C++
It is C language with additional features.
Widely used for developing system and application software.
Graphical user interfaces can be developed easily with visual
programming tools.
Windows Based
JAVA
An object-oriented language similar to C++ that eliminates lots of
C++s problematic features
Allows a web page developer to create programs for applications,
called applets that can be used through a browser.
Objective of JAVA developers is that it be machine, platform and
operating system independent. SlidecourtesyofBrianPichman
Special Programming Languages
Scripting Languages
JavaScript and VBScript
Php and ASP
Perl and Python
Command Languages
sh, csh, bash, cmd

SlidecourtesyofBrianPichman
Special Programming Languages
HTML
HyperText Markup Language.
Used on the Internet and the World Wide Web (WWW).
Web page developer puts brief codes called tags in the page to
indicate how the page should be formatted.
XML
Extensible Markup Language.
A language for defining other languages.

SlidecourtesyofBrianPichman
What do you want to make?
Source: https://www.udemy.com/
Source: https://www.udemy.com/
Source: https://www.udemy.com/
Source: https://www.udemy.com/
Otherwaystolearncoding
See how things on the Web work behind the scenes using

http://getfirebug.com/
SCRATCH Basics

Scratchisaprogramminglanguageforeveryone.Create
interactivestories,games,musicandartandsharethemonline.
.mit.edu
FinchRobot,ca.$100

http://www.finchrobot.com/
Ozobot,ca.$60

http://www.ozobot.com/
LegoWeDo/LegoMindstorms
Spheroca.$130

http://www.sphero.com/
DashandDot,ca.$149

https://www.makewonder.com/
Interact with the real world
using the Tickle App
Learn to program Arduino, drones, robots, connected
toys, and smart home devices, all wirelessly.

https://tickleapp.com
HopscotchApp

https://www.gethopscotch.com/
pinocc.io,ca.$197
http://www.slideshare.net/chadmairn

@cmairn
Want to
Hangout?

gplus.to/chadmairn

You might also like