Class Notes (835,246)
United States (324,066)
COMPSCI 61A (133)
De Nero (43)
Lecture 10

# CS61A Lecture 10: Data Abstraction

3 Pages
142 Views

Department
Computer Science
Course
COMPSCI 61A
Professor
De Nero
Semester
Fall

Description
Data Every value has a type, ex. type(1) = int type(2.2) = float type(1 + 1j) = complex type(True / False ) = bool True + True = 2 Properties of data types: primitive expressions that evaluate to values of types built-in functions, operators, methods manipulate values int exact number float finite approximation complex Objects Objects represent information Consist of data + behavior, bundled together create abstractions Can represent things, numbers, processes, interactions Type of object = Class Class are first class values in Python Object oriented programming: metaphor for organizing large programs special syntax that improve composition of programs In Python, every value is an object all objects have attributes a lot of data manipulation through object methods function do one thing, objects do many related things Data Abstraction Compound objects combine objects A date: year, month, day A geographic position: longitude , latitude An abstract data type allows manipulation compound objects as units Isolate any two parts of program that use data How data represented (as parts) How data manipulated (as units) Data abstraction: methodology by which functions enforce abstraction barrier between representation and use Rational Numbers numerator / denominator, both are integers exact representation of fractions ( 1 / 3 ) not exact, finite approximation Assume we can decompose & compose rational numbers rational(n, d), return rational number X ---> Constructors numer(x) return numerator x ---> Selectors denom(x) return denominator x ---> Selectors Pairs as Tuples A tuple literal: comma-separated expression pair = (1, 2) x, y = pair x = 1, y =
More Less

Related notes for COMPSCI 61A
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.