15
1/14/13 1 CS 101 Computer Science I Spring 2013 Robert Muller Today What this course is about LogisBcs Course administraBon Computer Science I Super TA Staff Head TA: Meg Bednarcik Danielle Corde Fiona Tamburini Pine Wu Computer Science I

CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

1%

CS%101%Computer%Science%I%

Spring%2013%Robert%Muller%

Today%

•  What%this%course%is%about%

•  LogisBcs%

•  Course%administraBon%

Computer%Science%I%

Super%TA%Staff%

•  Head%TA:%Meg%Bednarcik%

•  Danielle%Corde%

•  Fiona%Tamburini%

•  Pine%Wu%

Computer%Science%I%

Page 2: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

2%

What%this%course%is%about%

•  An%introducBon%to%Computer%Science%

•  First%step%is%learning%how%to%“program”%a%compuBng%device;%– DraQing%

•  Have%an%idea?%You%can%make%it%happen!%

Computer%Science%I%

Computer%Science%I%

350%Million%Mile%Journey,%Lands%1.5M%from%Target%

Computer%Science%I%

Page 3: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

3%

Central%Dogma%of%Molecular%Biology%

Computer%Science%I%

Computer%Science%I%

Computer%Science%I%

Page 4: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

4%

What%this%course%is%about%

•  We%will%use%Java%Python%as%our%programming%language%

•  We%will%have%about%10%programming%projects%

•  By%the%end%of%the%semester%%– You’ll%be%a%competent%python%programmer%– You’ll%have%a%be\er%understanding%of%computer%science%%

Computer%Science%I%

What%this%course%is%about%

•  Central%idea:%learning%to%develop%and%express%algorithms%

•  How%to%build%stuff!%

•  CS%M/O:%– Learn&by&doing!&– The%more%you%do%the%be\er%you%get%at%it%

Computer%Science%I%

Computer%Science%and%Math%

•  Like%mathemaBcs,%computer%science%emphasizes%problem%solving,%%

•  In%many%ways%programming%is%like%applied%or%“acBve”%algebra:%

f(x)%=%ax2%+%bx%+%c%

•  In%Python:%def%f(x):%return%a%*%x%**%2%+%b%*%x%+%c%

Computer%Science%I%

Page 5: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

5%

Euclid’s%Algorithm,%300BCE%

%%%%%%%% % %%%%%%%%!%m% % % % %%% % %if%n%is%0,%%gcd(m,%n)%=%%"%%% % %%%%%%%%#%gcd(n,%m%%%n)% % %otherwise%%%

Computer%Science%I%

gcd(25,%10)%=%gcd(10,%5)%=%gcd(5,%0)%=%5%

Euclid’s%Algorithm,%300BCE%

%%%%%%%% % %%%%%%%%!%m% % % % %%% % %if%n%is%0,%%gcd(m,%n)%=%%"%%% % %%%%%%%%#%gcd(n,%m%%%n)% % %otherwise%%%

Computer%Science%I%

def%gcd(m,%n):%%if%n%==%0:%%% % %return%m%%%else:%%% % %return%gcd(n,%m%%%n)%

Computer%Science%and%Math%

•  But%mathemaBcs%is%more%concerned%with%“what”%quesBons%whereas%computer%science%is%more%concerned%with%process%and%“how”:%

%math:%2%*%3%+%4%IS&10%

%computer+science:%2%*%3%+%4%%6%+%4%%10%takes%2%steps,%…%

Computer%Science%I%

Page 6: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

6%

IDLE%Demo%

Computer%Science%I%

Rough%Outline%

•  1.%Basics%•  2.%CondiBonals%•  3.%RepeBBon%•  4.%Structured%Data%(Lists)%•  5.%Working%with%Digital%Audio%•  6.%Working%with%FuncBon%Values%•  7.%Working%with%Tuples,%Maps%and%Trees%•  8.%Storage%and%MutaBon%•  9.%Markov%Models%•  10.%Working%with%Digital%Images%

Computer%Science%I%

Workload%

•  Most%of%our%material%is%covered%in%lecture,%background%reading%in%HM%CS5%Book%or%Downey.%

•  10%Programming%projects%

•  Two%midterm%exams%and%a%final%(roughly%every%5%weeks)%

Computer%Science%I%

Page 7: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

7%

Grading%

•  45%%for%~10%problem%sets,%plenty%of%opportunity%for%extra%credit%

•  45%%for%3%exams%

•  10%%for%consistent%class%parBcipaBon%– Class,%secBon,%Piazza%

Computer%Science%I%

How%to%Succeed%in%CS%101%

•  Start%problem%sets%right+away!%

•  Pay%careful%a\enBon%to%detail.%

•  Seek%help%when%you%need%it.%

•  Show%up%consistently,%parBcipate%in%class,%ask%quesBons.%

Computer%Science%I%

Where%did%compuBng%come%from?%

Computer%Science%I%

Page 8: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

8%

Blombos%Cave,%South%Africa%%%77,000%Years%Ago%

Computer%Science%I%

From%CounBng%to%ArithmeBc%

Sumeria%

5,000%Years%Ago%

Computer%Science%I%

From%ArithmeBc%to%Algebra%Brahmagupta%(640AD)%

FoundaBonal%wriBngs%on%algebra%and%astronomy.%His%text%on%astronomy,%The%Brahmasphutasiddhanta+is%the%earliest%known%text%to%treat%zero%as%a%numeral%in%its%own%right.%This%text%was%taken%to%Baghdad%~800AD.%Its%translaBon%transformed%the%Arab%world.%Computer%Science%I%

Page 9: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

9%

Hindu%Numeral%System%

•  Developed%in%fits%and%starts%over%5,000%years%

•  Key%InnovaBons:%– Numerals%as%strings%of%decimal%digits%{0,%1,%…,%9}%

– Meaning%(value)%of%an%occurrence%of%a%digit%depends%on%its%rightutouleQ%posiBon%in%the%string%

– Zero%(!)%–%first%known%occurrence%in%India%~600AD%

Computer%Science%I%

Muhammad%ibn%Mūsā%aluKhwārizmī%

~830AD%A%mathemaBcian%and%scholar%in%the%House%of%Wisdom%in%Baghdad.%AQer%the%Islamic%conquest%of%Persia,%Baghdad%became%the%center%of%scienBfic%studies%and%trade.%%%

• %The+Compendious+Book+on+Calcula8on+by+Comple8on+and+Balancing+(al%jabr)%

• %On+the+Calcula8on+with+Hindu+Numerals.%

Computer%Science%I%

Fibonacci%(1170%–%1250)%

Book+of+Calcula8on+

Introduc8on+in+Europe+revolu8onized+western+culture.%

Computer%Science%I%

Page 10: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

10%

Gottfried Wilhelm Leibniz (1646-1714)%

•  Infinitesimal Calculus

•  Binary Numeral System

10110

1012%

Computer%Science%I%

%...+it+is+beneath+the+dignity+of+excellent+men+to+waste+their+8me+in+calcula8on+when+any+peasant+could+do+the+work+just+as+accurately+with+the+aid+of+a+machine.+

—uu%Go|ried%Leibniz%

Computer%Science%I%

Leibniz’%Stepped+Reckoner%(1672)%AddiBon,%SubtracBon,%MulBplicaBon,%Division%

Computer%Science%I%

Page 11: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

11%

Computer%Science%I%

Computer%Science%I%

Computer%Science%I%

Page 12: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

12%

Computer%Science%I%

How%a%compuBng%device%works%

•  Each%machine%has%a%fixed%set%of%500%or%so%simple%instrucBons%that%it%“knows”%how%to%execute.%%–  Different%computers%will%have%different%sets%of%instrucBons%

•  Each%instrucBon%is%assigned%a%unique%pa\ern%of%1’s%and%0’s%(which%we%usually%think%of%as%a%binary%number)%

•  For%example:%–  0000%might%mean%ADD%2%numbers%–  0001%might%mean%SUBTRACT%2%numbers%–  0010%might%mean%COMPARE%2%numbers%…%

Computer%Science%I%

How%a%compuBng%device%works%

•  These%binary%instrucBon%codes%can%be%stored%in%the%computer’s%memory%

•  The%computer%can%execute%a%program%by%interpreBng%the%binary%instrucBon%codes%in%memory,%one%aQer%another%(REALLY%FAST!)%

Computer%Science%I%

Page 13: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

13%

How%a%compuBng%device%works%

•  Machine%languages%have%text%representaBons%that%make%them%more%understandable%to%humans.%This%is%called%assembly+language.%

•  One%can%program%in%this%lowulevel%assembly%language%and%use%a%program%(an%assembler)%to%translate%the%text%to%the%binary%form%(it’s%fun%but%also%a%lot%of%work!)%

Computer%Science%I%

MIPS%Demo%

Computer%Science%I%

How%Programming%Works%

•  Using%an%editor+program,%a%programmer%develops%the%TEXT%of%a%program%in%some%language,%e.g.,%Python%

•  They%then%use%another%program,%a%compiler,%to%translate+the%text%into%the%binary%language%of%the%machine.%

Computer%Science%I%

Page 14: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

14%

Programming%(Basic%Model)%

Computer%Science%I%

Python%Program%

Python%Compiler%

Binary%Program%

Binary%Program%is%in%the%naBve%language%of%the%computer%so%the%binary%program%can%be%executed.%

Programming%(Basic%Model)%

Computer%Science%I%

Python%Program%

Python%Compiler%

Binary%Program%

Since%each%computer%has%it’s%own%naBve%language,%a%compiler%that%can%produce%binaries%for%one%computer%won’t%necessarily%be%able%to%produce%binaries%that%will%run%on%a%different%computer.%

Programming%(VM%Model)%

Computer%Science%I%

Python%Program%

Python%Compiler%

Byte%Code%VM%Program%

The%Byte%Code%Program%is%in%the%naBve%language%of%a%“virtual”%computer.%The%virtual%machine%(VM)%is%just%a%program%that%can%be%implemented%on%any%computer,%no%ma\er%it’s%binary%language.%

Page 15: CS%101%Computer%Science%I% Today%muller/teaching/cs101/s13/dist/docs/01Introduction… · 1/14/13% 3% Central%Dogma%of%Molecular%Biology% Computer%Science%I% Computer%Science%I% Computer%Science%I%

1/14/13%

15%

Programming%(VM%Model)%

Computer%Science%I%

Python%Program%

Python%Compiler%

Byte%Code%VM%Program%

Python%Virtual%Machine%

VM%

The%VM%runs%on%the%computer%and%your%program%“runs”%on%the%VM!%

Tour%of%course%website%

Computer%Science%I%

Topics%&%Approximate%Schedule%

•  Learn%Python%– FuncBons%– Branching%–  IteraBon%

•  Projects%– Simple%Apps,%Graphics,%…%

– Puzzles%and/or%Games%– Audio,%Image%Processing,%Biology%

Computer%Science%I%