1 / 24

Some Basics See Chapters 1 & 2 Describe the basic features of an algorithm

Some Basics See Chapters 1 & 2 Describe the basic features of an algorithm Explain how hardware and software collaborate in a computer’s architecture Give a brief history of computing Run a simple Python program Strings, integers and floating point numbers

ivory
Download Presentation

Some Basics See Chapters 1 & 2 Describe the basic features of an algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Some BasicsSee Chapters 1 & 2 Describe the basic features of an algorithm Explain how hardware and software collaborate in a computer’s architecture Give a brief history of computing Run a simple Python program Strings, integers and floating point numbers Initialize and use variables with appropriate names

  2. Processing IPO Model Outputs Inputs

  3. Fundamentals of Computer Science: Algorithms and Information Processing • Computer science focuses on a broad set of interrelated ideas • Two of the most fundamental ones are: • Information processingIn carrying out the instructions of an algorithm, “computing agent” manipulates data (or information)Starts with input -> produces output • Algorithms

  4. Algorithms • Steps for determining change when paying for something (i.e., subtracting two numbers): • Step 1: Write down the numbers, with larger number above smaller one, digits column-aligned from right • Step 2: Start with rightmost column of digits and work your way left through the various columns • Step 3: Write down difference between the digits in the current column of digits, borrowing a 1 from the top number’s next column to the left if necessary • Step 4: If there is no next column to the left, stop • Otherwise, move to column to the left; go to Step 3 • The computing agent is a human being

  5. Algorithms (continued) • Sequence of steps that describes each of these computational processes is called an algorithm • Features of an algorithm: • Consists of a finite number of instructions • Each individual instruction is well defined • Describes a process that eventually halts after arriving at a solution to a problem (or so we hope :-D ) • Solves a general class of problems

  6. The Structure of a Modern Computer System • A modern computer system consists of hardware and software • Hardware: physical devices required to execute algorithms • Software: set of these algorithms, represented as programs in particular programming languages

  7. Computer Hardware Computers can also communicate with the external world through various ports that connect them to networks and to other devices

  8. Computer Hardware (continued) Random access memory (RAM) is also called internal or primary External or secondary memory can be magnetic, semiconductor, or optical

  9. Computer Software • A program stored in computer memory must be represented in binary digits, or machine code • A loader takes a set of machine language instructions as input and loads them into the appropriate memory locations • The most important example of system software is a computer’s operating system • Some important parts: file system, user interfaces (terminal-based or GUIs) • Applications include Web browsers, games, etc.

  10. Computer Software (continued)

  11. Genealogy of Common Languages

  12. Getting Started with Python Programming • Early 1990s: Guido van Rossum • invented the Python programming language • Python is a high-level, general-purpose programming language for solving problems on modern computer systems • Useful resources at www.python.org • Extensive Python documentation atpython.org/doc/ • Python 3.2: www.python.org/download/releases/3.2.3The programming language for this course. Note that we are using Python 3, not Python 2.

  13. Running Code in the Interactive Shell • Python is an interpreted language • Simple Python expressions and statements can be run in the shell • Easiest way to open a Python shell is to launch the IDLE or WING • Shell is useful for: • Experimenting with short expressions or statements • Do this! You can’t break the computer by doing so! • Consulting the documentation

  14. Running Code in the Interactive Shell (continued)

  15. Input, Processing, and Output • Programs usually accept inputs from a source, process them, and output results to a destination • In terminal-based interactive programs, these are the keyboard and terminal display

  16. Behind the Scenes:How Python Works We will talk more about this next class!

  17. Data Types & Assignments • Text processing is by far the most common application of computing • E-mail, text messaging, Web pages, and word processing all rely on and manipulate data consisting of strings of characters • Although the first applications of computers were to crunch numbers • The use of numbers in many applications is still very important

  18. Data Types & Assignments (cont’d) A data type consists of a set of values and a set of operations that can be performed on those values

  19. Integers • In real life, the range of integers is infinite • A computer’s memory places a limit on magnitude of the largest positive and negative integers • Python’s inttypical range: –231 to 231 – 1 • Integer literals are written without commas

  20. Floating-Point Numbers Python uses floating-point numbers to represent real numbers Python’s floattypical range: –10308 to 10308 and Typical precision: 16 digits

  21. Floating-Point Numbers (continued)

  22. Variables and the Assignment Statement • A variable refers to a value in the memory • Makes it easy to remember and use later in program • Variable naming rules: • Reserved words cannot be used as variable names • Examples: if, def, and import • Name must begin with a letter or _ (underscore) • Name can contain any number of letters, digits, or _ • Names are case sensitive • Example: WEIGHT is different from weight

  23. Variables and the Assignment Statement (continued) • Programmers use all uppercase letters for symbolic constants • Examples: TAX_RATEand STANDARD_DEDUCTION • Variables receive initial values and can be reset to new values with an assignment statement <variable name> = <expression>

  24. Required Readings Fundamentals of PythonSections 1.4, 1.4.1, 1.4.2, 2.3.1, 2.3.5, 2.4.1, 2.4.2.

More Related