1/16/13 CS108 Lecture 01: Introduction Computing and Programming Concepts Introduction to Python Aaron Stevens 16 January 2013 Computer Science What You ’ ll Learn Today Computer Science What is computer science? What is a computer? What are hardware and software? How can computers learn new tricks? What is Programming? What is Python? 1
1/16/13 What is Computer Science? Computer Science CS is NOT Science! Computer Science The fundamental ideas of CS are: Algorithms Protocols Encoding Information Abstraction 2
1/16/13 Algorithm Computer Science An algorithm is a sequence of clear and precise step-by-step instructions for solving a problem in a finite amount of time. Protocols Computer Science A protocol is a set of rules governing the exchange or transmission of data between devices. 3
1/16/13 Encoding Example: Braille Computer Science Each character is up to 6 dots. Each dot is either on or off. Invented by Louis Braille (1809-1852). Abstraction Computer Science Abstraction is about hiding unnecessary details and retaining only the relevant information. 4
1/16/13 What is a Computer? Computer Science What is a computer, anyway? A computer takes an input, applies a process, and produces an output. Give some examples: 2 What is a Computer? Computer Science 5
1/16/13 Hardware Computer Science 3 Software Computer Science 3 6
1/16/13 Early History of Computing Computer Science Joseph Jacquard (1801) Jacquard ’ s Loom, the punched card Programmability Computer Science What tricks does your computer do? – Web browsing, email, instant messenger – Play games – Watch movies, organize photos – Word processing, spreadsheets, database Programmability is the ability to give a general- purpose computer instructions so that it can perform new tasks. 3 7
1/16/13 Programming Languages Computer Science A program is a sequence of instructions. Spock: Computer. This is a Class-A compulsory directive. Compute, to the last digit, the value of pi. Computers are not very good at understanding natural languages Ambiguity and imprecision Dialects, accents, etc Programming Languages Computer Science Computer languages are exact and unambiguous. Programming is the process of encoding our ideas for the computer: Syntax (form) Semantics (meaning) Popular programming languages: BASIC, C++, Java, Perl, Python 8
1/16/13 Machine Language Computer Science Computing hardware performs only a small set of concrete operations, which are created in circuitry: 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 These instructions must be provided to the CPU as binary notation (1s and 0s), called machine language High Level Languages Computer Science Python is a high-level language c = a + b print c High level languages are more natural for us to understand, but need to be translated into the machine language for execution. 9
1/16/13 Compiled Language Computer Science Source Code Machine Code Compiler (Program) Program Running Outputs Inputs Program A compiler takes source code, and produces executable machine code (stored in a file on disk). The machine code program is executed by the user. Advantage: speed at time of execution. Interpreted Language Computer Science Source Code (Program) Computer Outputs Running an Interpreter Inputs An interpreter takes source code as input, and then compiles each statement and executes it immediately. Advantage: portability 10
1/16/13 The Python Programming Language Computer Science CS108 will use the Python programming language. What is Python? Python is an interpreted language, with both procedural and object- oriented features. Runs on Windows, Linux/Unix, Mac OS X, OS/2, Amiga, Palm Handhelds, Nokia mobile phones, and any device which supports Java. Computer Science 11
1/16/13 Introducing Python Computer Science Python Interactive Mode, Command Prompt Python ’ s Interactive Mode (Command Line) Computer Science Some simple output statements, and a hint of arithmetic 12
1/16/13 Python ’ s Interpreted Mode (Saved Program) Computer Science Write code once, run-many What You Learned Today Computer Science Computer Science is… A Computer is… Hardware vs. Software Programmability Programming Languages Machine language vs. high level Compiled vs. Intepreted Introducing Python Interactive (command-line) mode Interpreted (saved-program) mode 13
1/16/13 Setting up a CS account Computer Science Announcements and To Do List Computer Science Lab 1: Sign up for lab account try out websubmit Do this on Thursday. Readings: Zelle 1.1-1.8 (this week) Bring computer to class next time (with Python and IDLE editor installed) Go to www.python.org to download it. VERSION 2.7.3 http://www.python.org/download/releases/2.7.3/ 14
Recommend
More recommend