CMPT 120 - PowerPoint PPT Presentation

About This Presentation
Title:

CMPT 120

Description:

The majority of the time we aren't concerned with the computer itself (hardware) ... Artificial Intelligence, Human-Computer Interaction, Graphics, Natural ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 20
Provided by: chr15
Category:

less

Transcript and Presenter's Notes

Title: CMPT 120


1
CMPT 120
  • Introduction to Computer Science and Programming
    I
  • Chris Schmidt

2
CMPT 120
  • What will you learn?
  • Basic concepts of Computing Science
  • How computers store some types of data
  • Algorithms (methods of solving problems)
  • Data Structures (how to store complex data)
  • How to analyze and compare algorithms
  • How to write programs in Python

3
Computing Science
  • Comput-ing Science
  • The majority of the time we arent concerned with
    the computer itself (hardware)
  • The main concern is the creation, analysis, and
    application of algorithms
  • Hard to pin down a good definition

4
Computing Science
  • Computing Science is an extremely diverse field
    ranging from the completely theoretical to the
    very practical
  • Logic, Complexity and Computability, Database
    Management, Artificial Intelligence,
    Human-Computer Interaction, Graphics, Natural
    Language Processing, Operating Systems,
    Programming Languages, Networking,
    Bioinformatics, Computer Architecture, Software
    Engineering

5
The Basics
  • Hardware
  • Physical equipment (processor, monitor, keyboard,
    printer)
  • If you can touch it, its hardware
  • Software
  • Programs (sets of instructions) that run on the
    hardware

6
Hardware
  • Some Basic Computer Components
  • CPU Central Processing Unit
  • The computers central brain
  • ALU Arithmetic and Logic Unit
  • Memory
  • ROM Read Only Memory
  • RAM Random Access Memory
  • Storage
  • Hard Disk, CD-Rom, etc.
  • Input
  • Keyboard, Mouse
  • Output
  • Monitor, Printer

7
Software
  • Computer Program
  • A set of instructions that the computer will
    complete
  • The instructions that are used are defined by a
    programming language

8
Programming Languages
  • High Level Languages
  • The languages you usually here about are high
    level languages (Python, C, Java, Visual
    Basic..
  • These languages are used to write the everyday
    applications we see
  • Use complex instructions that cant be directly
    understood by a computers hardware

9
High Level Code (Python)
  • metres float(raw_input( \ "Enter your height
    (in metres) "))
  • total_inches 39.37 metres
  • feet int(total_inches/12)
  • inches total_inches - feet12
  • print "You are " str(feet) " feet and " \
    str(inches) " inches tall."

10
Programming Languages
  • Machine Language
  • Processors have a small set of simple
    instructions they understand
  • Access/store a value, add two values, compare two
    values,
  • Different processor types have different
    instructions
  • Each instruction is identified by a unique number

11
Programming Languages
  • Assembly Language
  • Machine language is difficult for humans to work
    with directly (its all numbers)
  • Assembly Language is one step higher
  • The instructions are given short names
    (mnemonics) so it is readable
  • A compiler converts the text of a program in
    assembly language into the appropriate Machine
    Language

12
Assembly Language Code
  • ORG 0000
  • N1 DB 11110100
  • N2 DB !41
  • ANS1 RMB 1
  • ANS2 RMB 1
  • ORG 0010
  • START LDS 00FF
  • LDD !0
  • LDX !0
  • LDY !0
  • PSHA
  • LDAA N1
  • PSHA
  • .
  • .

13
Programming Languages
  • Back to High Level Languages
  • Instead of using the simple instructions of
    assembly language we work with more readable high
    level languages
  • As with assembly language a compiler or
    interpreter is needed to convert the code to the
    machine language

14
Python
  • Interpreted vs Compiled
  • Compiled languages (C, Java) are written as
    text and then must be compiled into machine code
  • Interpreted languages (Python) are written as
    text, but do not need to be compiled. When run,
    an interpreter, converts the code line by line

15
Advantages
  • Compiling
  • Faster at runtime, no translation to machine code
    needed
  • Interpreting
  • More flexibility when editing, dont have to
    recompile every time you want to test a change
  • More flexible at runtime (though we probably
    wont take advantage of this in 120)

16
Hello World!
  • The first program people often write simply tells
    the computer to print the phrase Hello World!
  • The simplicity of a language can be seen to some
    extent by how complex the code needed to do this
    is.

17
Hello World!
  • Python
  • print "Hello World!"
  • C
  • include ltiostreamgt
  • using namespace std
  • int main ()
  • cout ltlt "Hello World!"
  • return 0
  • Java
  • public class HelloWorld
  • public static void main(String args)
  • System.out.print("Hello World!")

18
Python Powers of Two
  • print "The first ten powers of 2."
  • x1
  • for i in range(10)
  • print x,
  • xx2

19
C Powers of Two
  • include ltiostreamgt
  • using namespace std
  • int main ()
  • int x 1
  • cout ltlt "The first ten powers of 2.\n"
  • for (int i0 i lt 10 i)
  • cout ltlt x ltlt " "
  • x x2
  • return 0
Write a Comment
User Comments (0)
About PowerShow.com