welcome to computer programming€¦ · welcome to computer programming ljubov jaanuska msc in...

19
WELCOME TO COMPUTER PROGRAMMING

Upload: others

Post on 29-Jun-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

WELCOMETOCOMPUTERPROGRAMMING

Page 2: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

LjubovJaanuska

MScincomputerscience

TeachingAssistantinInforma6cs

Ins6tuteofComputerScience,UniversityofTartu

[email protected]

Page 3: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

WHATABOUTYOU?

Name?

Whatareyoustudying?

Whereareyoufrom?

Previousexperience?

Page 4: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Whyshouldwelearnprogramming?

???

Page 5: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Courseoverview

Materials-hIps://courses.cs.ut.ee/

Tests,submissionofexercises,points-

hIps://moodle.ut.ee/

Page 6: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Grading

hIps://courses.cs.ut.ee/2017/nkp/fall/Main/Grading

•  Tests•  Homework+par6cipa6oninthesessions

•  Project(formula6on+solu6on)

•  Mid-termtest

•  Exam(testonpaper+programmingexercise)

Page 7: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Sessions

• Before:• Video• Test• Homework

• Sessions• Wednesday

• Thursday

Page 8: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

SoKware

• Python2orPython3• IDLEorNotepad++• CMD???

Page 9: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

QuesMonnaire

hIps://goo.gl/forms/7oI4hpqhQjiOWMru1

Page 10: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Bynow…

• Independentlycovered2chaptersofCharlesSeverance:• 2videoslectures• 1test

Page 11: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

PROGRAMMING

•  Computerswanttobehelpful

butweneedtospeaktheirlanguage

• Programmersarepeoplewhoknowhowtocommunicatewithcomputers

inaprogramminglanguage.

Theyknowhowtowriteprograms

• Programisasequenceofstoredinstruc6ons(commands)

• Programmersfigureoutthesequenceandencodeit

>WRITEABOOK>ERROR

Page 12: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Python

• Python• AprogramminglanguagedevelopedbyGuidovanRossumin1991

• Awaytocommunicatewithcomputersandencapsulateour

instruc6ons

Page 13: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Advice

Atthebeginning,thelanguageisnew.Itishardlypossibletopickupa

languageoverthenight.

Therewillbelotsofmistakes(e.g.syntaxerror):•  PCisnotcruelnormakingjokes

•  Itsays:“Idon’tunderstandwhatyouaresaying.Ionlyknowafewwords.PleasespeakinPython.”

•  BereadythatPCdon’tcorrectyouasteachersdo.TheycanhardlylistenorunderstandourawkwardShakespearianPython

Keepgoing,wonderingthroughout,ediMng,playing,understanding•  ItiseasierforyoutolearnPythonthantomakecomputersunderstandEnglish

Page 14: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

WHY PYTHON?

Python:

print"Hello,world!"

Java:

publicclassHelloWorld{

publicsta6cvoidmain(String[]args){

System.out.println("Hello,world!");

}

}

Page 15: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

InteracMveorScript•  InteracMvePython•  Youtypedirectlyonelineata6meandPythonresponds

•  Isgoodforexperimentsandprogramsof3-4lines

• PythonScript•  Youenterasequenceofstatements(lines)intoafileusingatexteditorand

tellPythontoexecutethestatementsinthefile

•  add.pyasthesuffixontheendofthesefilestoindicatetheycontainPython

Page 16: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Chapter2-Expressions• Variables• mnemomicallynamedplaceinthememorywhereaprogrammercanstore

dataandlaterretrievedatausingthevariablename

• MuststartwithaleIerorunderscore_

• MustcontainleIers,numbersorunderscore

•  CasesensiMve

• Constants•  Numbers,leIers,andstringareconstants

•  Theydonotchangetheirvalue•  123 98.6 ‘Hello, world’ “Hello, world”

•  type() •  Types int float str •  Typeconversion int() float() str()

Page 17: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Expressions•  Assignmentstatement

•  e.g.x = 2 •  Hey, Python, go and find a place called ‘x’ and store there 2

•  Assignmentwithexpression(e.g.x = x + 2 )

•  Operators •  Addition + •  Substracion - •  Multiplication * •  Division / Truncateddivision450 / 100resultis4 vs 450.0 / 100 resultis4.5

•  Power ** •  Remainder or moder % (450 % 100 resultis50)

OrderofevaluaMon(operatorprecedence) () ** */% +-leptoright

Page 18: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Expressions

• Reservedwords(e.g.print, for, elif, while)• Userinputraw_input(‘Hello’) • Comments #

Page 19: WELCOME TO COMPUTER PROGRAMMING€¦ · WELCOME TO COMPUTER PROGRAMMING Ljubov Jaanuska MSc in computer science ... • PC is not cruel nor making jokes • It says: ... • 123 98.6

Test1

Ques6ons?