20
CSc 10200 Introduction to Computing Lecture 1 Edgardo Molina Spring 2011 - City College of New York Tuesday, February 1, 2011

CSc 10200 Introduction to Computing - CCVCL :: Homepagevisionlab.engr.ccny.cuny.edu/.../S11-cs102/lectures/extra-lecture1.pdf · CSc 10200 Introduction to Computing Lecture 1

  • Upload
    trannga

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

CSc 10200Introduction to Computing

Lecture 1Edgardo Molina

Spring 2011 - City College of New York

Tuesday, February 1, 2011

Syllabus

• Lecturer: Edgardo Molina

• TA: Tao Wang

• Grades

• Homework 40%• Quizzes 10%• Midterm Exam 20%• Final Exam 30%

Tuesday, February 1, 2011

Textbook (Recommended)

The Practice of Computing using Python

by William Punch and Richard Enbody

Tuesday, February 1, 2011

Textbook (GNU/FREE)

How to Think Like a Computer ScientistLearning With Python 2nd Edition

by Jeffrey Elkner, Allen B. Downey, and Chris Meyers

http://openbookproject.net/thinkcs/python/english2e/

Tuesday, February 1, 2011

What you will learn

• Basic structure and operation of a computer

• Code development (in Python)

• Debugging

• Programming with control structures

• Introduction to recursion

• Programming with array-like structures

• Standard library objects and functions

• Strings and input/output

• Problem solving

• Procedural programming

Tuesday, February 1, 2011

Tools

• RUR-PLE: A robot simulation environment for learning Python http://rur-ple.sourceforge.net/

• Python 2.6

• A good text editor

• Notepad++ (Windows)• TextWrangler (Mac OS X)• Kate/Gedit (Linux)• Many other choices....

• Avoid full blown IDE’s in this course

Tuesday, February 1, 2011

What is a computer?

Tuesday, February 1, 2011

Computer

Computer Organization

CPU

RAMInputsKeyboardMouseAudio inputWebcams...

OutputsScreenProjectorsPrinterSpeakers...

Hard Drive

Tuesday, February 1, 2011

Computer Organization

• Inputs: Provide a way to interact with the computer; provide it data

• Outputs: Provide a way to present processed information

• RAM (Random Access Memory): Is rapid access memory for active programs and data to be processed

• Hard Drive: Is slower access memory for long term storage of programs and data not in active use

• CPU (Central Processing Unit): performs the functions of the computer. Moves data from one place to another. Contains ALU (Arithmetic Logic Unit) to perform arithmetic and logical operations.

• Common CPU manufacturers: Intel, AMD, IBM• CPU Architectures: x86, x86-64, ARM, PPC

Tuesday, February 1, 2011

Software / Programs

• Computer Programs instruct the CPU which operations it should perform/execute

• Programmers write the code for the tasks a computer program performs

• But computers only understand binary (1’s and 0’s)

• Programmers need a language to write computer code

Tuesday, February 1, 2011

Types of Programming Languages

• Low-Level Languages

• Machine Languages

• CPU instructions are binary strings of 1’s and 0’s [10010000]

• Each kind of CPU has different instruction sets

• Programs are not portable across CPU’s architectures

• Difficult for programmers to read/write

• Assembly Languages

• Use english-like abbreviations to represent CPU instructions

• A bit easier to understand [MOV AL, 42h]

• Converted to machine language using an assembler

• Still not portable

Tuesday, February 1, 2011

Types of Programming Languages

• High-Level Languages

• C/C++, Java/C#, Python, Ruby, many more...

• These languages abstract hardware implementation details

• Provides programmers a logical computer model

• Allows programmer to focus on solving problems instead of low-level hardware details

• Use english-like keywords and statements to write code

• Use a compiler or interpreter that translates code to machine language

• Makes code portable across different CPU’s and platforms

• Programmer does not have to learn each CPU’s instructions

Tuesday, February 1, 2011

• Both Compilers and Interpreters translate source code to machine language

• Compiled

• Must compile program on each target CPU architecture prior to execution.

• Interpreted

• Code can be directly run on any platform that has an available interpreter

Compiled vs. Interpreted

Images from: How to Think Like a Computer Scientist: Learning with Python 2nd Edition

Tuesday, February 1, 2011

About Python

• Designed by Guido van Rossum in late 1980’s

• Interpreted programming language

• Imperative, Dynamic, and Object-Oriented

• Python Programs• are a sequence of instructions written in Python language• interpreter executes the instructions sequentially, in order• programs can take inputs and send data to outputs• programs can process and manipulate data• programs may read and write data to RAM, Hard Drive, ...

• First Program• print “Welcome to learning Python.“

Tuesday, February 1, 2011

RUR-PLE

Tuesday, February 1, 2011

About our robot...

• Can take one step forward move()

• Legs are broken, only left turns turn_left()

• Can pick things up pick_beeper()

• Can drop things put_beeper()

• Short battery life turn_off()

Tuesday, February 1, 2011

Lets pick things up...

• move()• move()• turn_left()• move()• pick_beeper()• turn_left()• turn_left()• turn_left()• move()• pick_beeper()• turn_off()

Tuesday, February 1, 2011

Lets pick things up... improved

• def turn_right():• turn_left()• turn_left()• turn_left()

• move()• move()• turn_left()• move()• pick_beeper()• turn_right()• move()• pick_beeper()• turn_off()

Tuesday, February 1, 2011

Known World

• Robot was told where he should pick things up

• What happens if there is nothing there?

Tuesday, February 1, 2011

Unknown World

• Robot should be able to make decisions to prevent crashing

Tuesday, February 1, 2011