![Page 1: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/1.jpg)
LING408/508:ProgrammingforLinguists
Lecture24
November30th
![Page 2: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/2.jpg)
Administrivia
• Youshouldbeworkingonyourprogrammingproject
• Homework11today– opJonal– easyopportunitytomakeuppoints– dueFridaynightbymidnight
![Page 3: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/3.jpg)
LastTime• Chapter6:
– CoolprogramtointeracJvelyspecifyatriangleandcalculateitsperimeter
![Page 4: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/4.jpg)
LastTime
![Page 5: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/5.jpg)
LastTime• Chapter7:DecisionStructures
– if <condition>: !<body> !
– elif <condition>: !<body> !
– else: !<body> !
– try: !<body> !
– except <error>: !<body> !
– except: !<body>!
![Page 6: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/6.jpg)
Today'sTopics
• Chapter8:LoopStructuresandBooleans
![Page 7: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/7.jpg)
condiJonalexecuJon• variable:__name__ !FileexecuJon/import• python file.py __name__ is '__main__' !• import file.py __name__ is 'file' !
![Page 8: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/8.jpg)
Loops• Alreadyseenforloops:
• while<condiJon>:<body>
sameas
![Page 9: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/9.jpg)
Loops
Problem:keepsprompJngforyes/no
![Page 10: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/10.jpg)
LoopsabeWerprogram:• usesraw_inputandeval !• whilelooptestsforemptystring
![Page 11: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/11.jpg)
Loops
Emptyline:includesanewline"\n"Endoffile:""
![Page 12: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/12.jpg)
Loops
mulJplenumbersononelineseparatedbycommas
![Page 13: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/13.jpg)
LoopandaHalf
![Page 14: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/14.jpg)
CondiJons
• bool:TrueorFalse
Javascript:• undefined,null,NaN,0and""arefalse• everythingelsewithavalueistrue
![Page 15: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/15.jpg)
comparisons
• CompoundcondiJonal:not <expr> !
notthesameas
![Page 16: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/16.jpg)
comparisons
• Defaultvaluesusingbooleans:
withimplicitcoercionofstringtobool
![Page 17: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/17.jpg)
comparisons
• Defaultvaluesusingbooleans:
aonelinewonder!(originalcodehad5lines)
![Page 18: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/18.jpg)
Homework11
• ImplementanytwooftheProgrammingProblemsinChapter8(pp.262–264)
![Page 19: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/19.jpg)
Chapter9
![Page 20: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/20.jpg)
Chapter9
• RacquetballsimulaJonprogram– useslibrarymodulerandom
![Page 21: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/21.jpg)
Chapter9
![Page 22: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/22.jpg)
Chapter9
![Page 23: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/23.jpg)
Chapter9
![Page 24: LING 408/508: Programming for Linguistssandiway/ling508-15/lecture24.pdf · Last Time • Chapter 6: – Cool program to interacJvely specify a triangle and calculate its perimeter](https://reader033.vdocuments.mx/reader033/viewer/2022051922/600f2dafe6bbf052714a6325/html5/thumbnails/24.jpg)
Chapter9