welcome to computer programming€¦ · welcome to computer programming ljubov jaanuska msc in...
TRANSCRIPT
WELCOMETOCOMPUTERPROGRAMMING
LjubovJaanuska
MScincomputerscience
TeachingAssistantinInforma6cs
Ins6tuteofComputerScience,UniversityofTartu
WHATABOUTYOU?
Name?
Whatareyoustudying?
Whereareyoufrom?
Previousexperience?
Whyshouldwelearnprogramming?
???
Courseoverview
Materials-hIps://courses.cs.ut.ee/
Tests,submissionofexercises,points-
hIps://moodle.ut.ee/
Grading
hIps://courses.cs.ut.ee/2017/nkp/fall/Main/Grading
• Tests• Homework+par6cipa6oninthesessions
• Project(formula6on+solu6on)
• Mid-termtest
• Exam(testonpaper+programmingexercise)
Sessions
• Before:• Video• Test• Homework
• Sessions• Wednesday
• Thursday
SoKware
• Python2orPython3• IDLEorNotepad++• CMD???
QuesMonnaire
hIps://goo.gl/forms/7oI4hpqhQjiOWMru1
Bynow…
• Independentlycovered2chaptersofCharlesSeverance:• 2videoslectures• 1test
PROGRAMMING
• Computerswanttobehelpful
butweneedtospeaktheirlanguage
• Programmersarepeoplewhoknowhowtocommunicatewithcomputers
inaprogramminglanguage.
Theyknowhowtowriteprograms
• Programisasequenceofstoredinstruc6ons(commands)
• Programmersfigureoutthesequenceandencodeit
>WRITEABOOK>ERROR
Python
• Python• AprogramminglanguagedevelopedbyGuidovanRossumin1991
• Awaytocommunicatewithcomputersandencapsulateour
instruc6ons
Advice
Atthebeginning,thelanguageisnew.Itishardlypossibletopickupa
languageoverthenight.
Therewillbelotsofmistakes(e.g.syntaxerror):• PCisnotcruelnormakingjokes
• Itsays:“Idon’tunderstandwhatyouaresaying.Ionlyknowafewwords.PleasespeakinPython.”
• BereadythatPCdon’tcorrectyouasteachersdo.TheycanhardlylistenorunderstandourawkwardShakespearianPython
Keepgoing,wonderingthroughout,ediMng,playing,understanding• ItiseasierforyoutolearnPythonthantomakecomputersunderstandEnglish
WHY PYTHON?
Python:
print"Hello,world!"
Java:
publicclassHelloWorld{
publicsta6cvoidmain(String[]args){
System.out.println("Hello,world!");
}
}
InteracMveorScript• InteracMvePython• Youtypedirectlyonelineata6meandPythonresponds
• Isgoodforexperimentsandprogramsof3-4lines
• PythonScript• Youenterasequenceofstatements(lines)intoafileusingatexteditorand
tellPythontoexecutethestatementsinthefile
• add.pyasthesuffixontheendofthesefilestoindicatetheycontainPython
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()
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
Expressions
• Reservedwords(e.g.print, for, elif, while)• Userinputraw_input(‘Hello’) • Comments #
Test1
Ques6ons?