《Py4Inf-01-Intro-PrintPy4Inf-01-Intro-Print》由会员分享,可在线阅读,更多相关《Py4Inf-01-Intro-PrintPy4Inf-01-Intro-Print(16页珍藏版)》请在金锄头文库上搜索。
1、Why Program?Chapter 1Python for Informatics: Exploring IUnless otherwise noted, the content of this course material is licensed under a Creative Commons Attribution 3.0 License.htp:/creativecommons.org/licenses/by/3.0/.Copyright 2010- Charles SeverancePre-Requisite: Please Instal Pythonhttp:/ to the
2、 Introduction.Computers want to be helpful.Computers are built for one purpose - to do things for usBut we need to speak their language to describe what we want doneUsers have it easy - someone already put many different programs (instructions) into the computer and users just pick the ones we want
3、to useWhatNext?WhatNext?WhatNext?WhatNext?WhatNext?WhatNext?WhatNext?Programmers Anticipate NeedsiPhone Applications are a marketiPhone Applications have over 3 Bilion downloadsProgrammers have left their jobs to be full-time iPhone developersProgrammers know the ways of the programPickMe!PickMe!Pic
4、kMe!PickMe!PayMe!PickMe!Users .vs. ProgrammersUsers see computers as a set of tools - word processor, spreadsheet, map, todo list, etc.Programmers learn the computer “ways” and the computer languageProgrammers have some tools that alow them to build new toolsProgrammers sometimes write tools for lot
5、s of users and sometimes programmers write little “helpers” for themselves to automate a taskComputerHardware + SoftwareNetworks.From a software creators point of view, we build the software. The end users (stakeholders/actors) are our masters - who we want to please - often they pay us money when t
6、hey are pleased. But the data, information, and networks are our problem to solve on their behalf. The hardware and software are our friends and allies in this quest.InformationDataUserProgrammerWhy be a programer?To get some task done - we are the user and programmerClean up survey dataTo produce s
7、omething for others to use - a programming jobFix a performance problem in the Sakai softwareAdd guestbook to a web siteWhat is Code? Software? A Program?A sequence of stored instructions It is a little piece of our intelligence in the computerIt is a little piece of our intelligence we can give to
8、others - we figure something out and then we encode it and then give it to someone else to save them the time and energy of figuring it outA piece of creative art - particularly when we do a god job on user experiencePrograms for Humans.http:/ for Humans.while music is playing:Left hand out and upRi
9、ght hand out and upFlip Left handFlip Right handLeft hand to right shoulderRight hand to left shoulderLeft hand to back of headRight ham to back of headLeft hand to right hitRight hand to left hitLeft hand on left bottomRight hand on right bottomWigleWigleJumphttp:/ for Humans.while music is playing
10、:Left hand out and upRight hand out and upFlip Left handFlip Right handLeft hand to right shoulderRight hand to left shoulderLeft hand to back of headRight ham to back of headLeft hand to right hitRight hand to left hitLeft hand on left bottomRight hand on right bottomWigleWigleJumphttp:/ for Humans
11、.while music is playing:Left hand out and upRight hand out and upFlip Left handFlip Right handLeft hand to right shoulderRight hand to left shoulderLeft hand to back of headRight hand to back of headLeft hand to right hipRight hand to left hipLeft hand on left bottomRight hand on right bottomWigleWi
12、gleJumphttp:/ clown ran after the car and the car ran into the tent and the tent fell down on the clown and the car Programs for Python. Programs for Python.name = raw_input(Enter file:)handle = open(name, r)text = handle.read()words = text.split()counts = dict()for word in words:countsword = counts
13、.get(word,0) + 1bigcount = Nonebigword = Nonefor word,count in counts.items():if bigcount is None or count bigcount:bigword = wordbigcount = countprint bigword, bigcountpython words.py Enter file: words.txtto 16python words.py Enter file: clown.txtthe 7Hardware Architecturehttp:/upload.wikimedia.org
14、/wikipedia/commons/3/3d/RaspberryPi.jpgSoftwareInputand OutputDevicesCentralProcessingUnitMainMemorySecondaryMemoryGenericComputerWhatNext?DefinitionsCentral Processing Unit: Runs the Program - The CPU is always wondering “what to do next”? Not the brains exactly - very dumb but very very fastInput
15、Devices: Keyboard, Mouse, Touch ScreenOutput Devices: Screen, Speakers, Printer, DVD BurnerMain Memory: Fast smal temporary storage - lost on reboot - aka RAMSecondary Memory: Slower large permanent storage - lasts until deleted - disk drive / memory stickWhatNext?SoftwareInputand OutputDevicesCentralProcessingUnitMainMemorySecondaryMemoryGener