《Py4Inf-01-IntroPy4Inf-01-IntroPy4Inf-01-IntroPy4Inf-01-Intro》由会员分享,可在线阅读,更多相关《Py4Inf-01-IntroPy4Inf-01-IntroPy4Inf-01-IntroPy4Inf-01-Intro(62页珍藏版)》请在金锄头文库上搜索。
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.http:/creativecommons.org/licenses/by/3.0/.Copyright 2010- Charles SeverancePre-Requisite: Please Install Pythonhttp:/ to t
2、he 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 wan
3、t to useWhatNext?WhatNext?WhatNext?WhatNext?WhatNext?WhatNext?WhatNext?Programmers Anticipate NeedsiPhone Applications are a marketiPhone Applications have over 3 Billion downloadsProgrammers have left their jobs to be full-time iPhone developersProgrammers know the ways of the programPickMe!PickMe!
4、PickMe!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 allow them to build new toolsProgrammers sometimes write tools for
5、 lots 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 wh
6、en they 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 produ
7、ce something 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
8、 to 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 good job on user experiencePrograms for Humans.http:/ for Humans.while music is playing:Left hand out and
9、 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 bottomWiggleWiggleJumphttp:/ for Humans.while music is
10、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 ham to back of headLeft hand to right hitRight hand to left hitLeft hand on left bottomRight hand on right bottomWiggleWiggleJumphttp:/ f
11、or Humans.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 bott
12、omWiggleWiggleJumphttp:/ 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:countswor
13、d = counts.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.wik
14、imedia.org/wikipedia/commons/3/3d/RaspberryPi.jpg SoftwareInputand 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 Devices: Keyboard, Mouse, Touch ScreenOutput Devices: Screen, Speakers, Printer, DVD BurnerMain Memory: Fast small temporary storage - lost on reboot - aka RAMSecondary Memory: Slower large permanent storage - lasts u