UK CS 115 - Python Programming: An Introduction to Computer Science

Unformatted text preview:

Python Programming: An Introduction to Computer ScienceObjectivesObjectives (cont.)The Universal MachineSlide 5Slide 6Program PowerSlide 8What is Computer Science?Slide 10Slide 11Slide 12Hardware BasicsSlide 14Slide 15Slide 16Programming LanguagesSlide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24The Magic of PythonSlide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Inside a Python ProgramSlide 36Slide 37Slide 38Slide 39Slide 40Slide 41Slide 42Slide 43Chaos and ComputersSlide 45Slide 46Python Programming, 2/e 1Python Programming:An Introduction toComputer ScienceChapter 1Computers and ProgramsObjectivesTo understand the respective roles of hardware and software in a computing system.To learn what computer scientists study and the techniques that they use.To understand the basic design of a modern computer.2Python Programming, 2/eObjectives (cont.)To understand the form and function of computer programming languages.To begin using the Python programming language.To learn about chaotic models and their implications for computing.3Python Programming, 2/eThe Universal MachineA modern computer can be defined as “a machine that stores and manipulates information under the control of a changeable program.”Two key elements:Computers are devices for manipulating information.Computers operate under the control of a changeable program.4Python Programming, 2/eThe Universal MachineWhat is a computer program?A detailed, step-by-step set of instructions telling a computer what to do.If we change the program, the computer performs a different set of actions or a different task.The machine stays the same, but the program changes!5Python Programming, 2/eThe Universal MachinePrograms are executed, or carried out.All computers have the same power, with suitable programming, i.e. each computer can do the things any other computer can do.6Python Programming, 2/eProgram PowerSoftware (programs) rule the hardware (the physical machine).The process of creating this software is called programming.Why learn to program?Fundamental part of computer scienceHaving an understanding of programming helps you have an understanding of the strengths and limitations of computers.7Python Programming, 2/eProgram PowerHelps you become a more intelligent user of computersIt can be fun!Form of expressionHelps the development of problem solving skills, especially in analyzing complex systems by reducing them to interactions between simpler systems.Programmers are in great demand!8Python Programming, 2/eWhat is Computer Science?It is not the study of computers!“Computers are to computer science what telescopes are to astronomy.” –E. DijkstraThe question becomes, “What processes can be described?”This question is really, “What can be computed?”9Python Programming, 2/eWhat is Computer Science?DesignOne way to show a particular problem can be solved is to actually design a solution.This is done by developing an algorithm, a step-by-step process for achieving the desired result.One problem – it can only answer in the positive. You can’t prove a negative!10Python Programming, 2/eWhat is Computer Science?AnalysisAnalysis is the process of examining algorithms and problems mathematically.Some seemingly simple problems are not solvable by any algorithm. These problems are said to be unsolvable.Problems can be intractable if they would take too long or take too much memory to be of practical value.11Python Programming, 2/eWhat is Computer Science?ExperimentationSome problems are too complex for analysis.Implement a system and then study its behavior.12Python Programming, 2/eHardware BasicsThe central processing unit (CPU) is the “brain” of a computer.The CPU carries out all the basic operations on the data.Examples: simple arithmetic operations, testing to see if two numbers are equal.13Python Programming, 2/eHardware BasicsMemory stores programs and data.CPU can only directly access information stored in main memory (RAM or Random Access Memory).Main memory is fast, but volatile, i.e. when the power is interrupted, the contents of memory are lost.Secondary memory provides more permanent storage: magnetic (hard drive, floppy), optical (CD, DVD)14Python Programming, 2/eHardware BasicsInput devicesInformation is passed to the computer through keyboards, mice, etc.Output devicesProcessed information is presented to the user through the monitor, printer, etc.15Python Programming, 2/eHardware BasicsFetch-Execute CycleFirst instruction retrieved from memoryDecode the instruction to see what it representsAppropriate action carried out.Next instruction fetched, decoded, and executed.Lather, rinse, repeat!16Python Programming, 2/eProgramming LanguagesNatural language has ambiguity and imprecision problems when used to describe complex algorithms.Programs expressed in an unambiguous , precise way using programming languages.Every structure in programming language has a precise form, called its syntaxEvery structure in programming language has a precise meaning, called its semantics.17Python Programming, 2/eProgramming LanguagesProgramming language like a code for writing the instructions the computer will follow.Programmers will often refer to their program as computer code.Process of writing an algorithm in a programming language often called coding.18Python Programming, 2/eProgramming LanguagesHigh-level computer languagesDesigned to be used and understood by humansLow-level languageComputer hardware can only understand a very low level language known as machine language19Python Programming, 2/eProgramming LanguagesAdd two numbers:Load the number from memory location 2001 into the CPULoad the number from memory location 2002 into the CPUAdd the two numbers in the CPUStore the result into location 2003In reality, these low-level instructions are represented in binary (1’s and 0’s)20Python Programming, 2/eProgramming LanguagesHigh-level languagec = a + bThis needs to be translated into machine language that the computer can execute.Compilers convert programs written in a high-level language into the machine language of some computer.21Python Programming, 2/eProgramming LanguagesInterpreters simulate a computer that understands a high-level language.The


View Full Document

UK CS 115 - Python Programming: An Introduction to Computer Science

Download Python Programming: An Introduction to Computer Science
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Python Programming: An Introduction to Computer Science and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Python Programming: An Introduction to Computer Science 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?