cs108 lecture 01: introduction - computer science

14
1/16/13 1 Computer Science CS108 Lecture 01: Introduction Computing and Programming Concepts Introduction to Python Aaron Stevens 16 January 2013 Computer Science What Youll Learn Today 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?

Upload: others

Post on 12-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

1/16/13

1

Computer Science

CS108 Lecture 01: Introduction

Computing and Programming Concepts Introduction to Python Aaron Stevens 16 January 2013

Computer Science

What You’ll Learn Today

 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/16/13

2

Computer Science

What is Computer Science?

Computer Science

CS is NOT Science!

The fundamental ideas of CS are:   Algorithms   Protocols   Encoding Information   Abstraction

1/16/13

3

Computer Science

Algorithm

An algorithm is a sequence of clear and precise step-by-step instructions for solving a problem in a finite amount of time.

Computer Science

Protocols

A protocol is a set of rules governing the exchange or transmission of data between devices.

1/16/13

4

Computer Science

Encoding Example: Braille

Each character is up to 6 dots. Each dot is either on or off.

Invented by Louis Braille (1809-1852).

Computer Science

Abstraction

Abstraction is about hiding unnecessary details and retaining only the relevant information.

1/16/13

5

Computer Science

2

What is a computer, anyway?

Give some examples:

What is a Computer?

A computer takes an input, applies a process, and produces an output.

Computer Science

What is a Computer?

1/16/13

6

Computer Science

3

Hardware

Computer Science

3

Software

1/16/13

7

Computer Science

Early History of Computing

Joseph Jacquard (1801) Jacquard’s Loom, the punched card

Computer Science

3

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.

Programmability

1/16/13

8

Computer Science

Programming Languages

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

Computer Science

Programming Languages

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

1/16/13

9

Computer Science

Machine Language

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

Computer Science

High Level Languages

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.

1/16/13

10

Computer Science

Compiled Language

Source Code (Program) Compiler

Machine Code Program

Inputs Running Program

Outputs

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.

Computer Science

Interpreted Language

Source Code (Program)

Computer Running

an Interpreter

Inputs

Outputs

An interpreter takes source code as input, and then compiles each statement and executes it immediately.

Advantage: portability

1/16/13

11

Computer Science

The Python Programming Language 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

1/16/13

12

Computer Science

Introducing Python

Python Interactive Mode, Command Prompt

Computer Science

Python’s Interactive Mode (Command Line)

Some simple output statements, and a hint of arithmetic

1/16/13

13

Computer Science

Python’s Interpreted Mode (Saved Program)

Write code once, run-many

Computer Science

What You Learned Today

 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

1/16/13

14

Computer Science

Setting up a CS account

Computer Science Announcements and To Do List

  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/