Busy. Please wait.

show password
Forgot Password?

Don't have an account?  Sign up 

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
We do not share your email address with others. It is only used to allow you to reset your password. For details read our Privacy Policy and Terms of Service.

Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.

Remove ads
Don't know
remaining cards
To flip the current card, click it or press the Spacebar key.  To move the current card to one of the three colored boxes, click on the box.  You may also press the UP ARROW key to move the card to the "Know" box, the DOWN ARROW key to move the card to the "Don't know" box, or the RIGHT ARROW key to move the card to the Remaining box.  You may also click on the card displayed in any of the three boxes to bring that card back to the center.

Pass complete!

"Know" box contains:
Time elapsed:
restart all cards

Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Objects and Classes


object In Python every value is stored in memory as an object. It is useful to think of an object as a container for the value that sits inside your computer's memory.
object type indicates kind of values object can hold and operations that can be performed on the object. Examples: integer (int), floating point (float), Boolean (bool), string (str), and list (list) type() function can be used to determine an object's type
variable and object type variables do not have types the objects variables refer to have types
object-oriented Python programming language is said to be object-oriented because values are always stored in objects. In programming languages other than Python, values of certain types are not stored in abstract entities such as objects but explicitly in memory.
class The term class is used to refer to types whose values are stored in objects. Because every value in Python is stored in an object, every Python type is a class. In this book, we will use class and type interchangeably.
float represents real numbers as fractions with finite decimal representations
number type and algebraic expressions If both operands x and y (are integers, the result is an integer. If one of the operands is a float value, the result is a float value. For division (/), the result is a float value, regardless of the operands.
7 comparison operators for numbers < Less than <= Less than or equal > Greater than >= Greater than or equal == Equal != Not equal
constructor explicitly instantiate object type x = int() float(), list(), and str()
Implicit type conversion float contains integer contains boolean If an algebraic or logical expression involves operands of different types, Python will convert each operand to the type that contains the others.
Operator Precedence List definition Indexing operator Exponentiation Positive, negative signs Product, division, integer division, remainder Addition, subtraction Comparisons, including membership and identity tests Boolean NOT Boolean AND Boolean OR
Explicit Type Conversions >>> int(3.4) 3 >>> float(3) 3.0 >>> str(2.72) ‘2.72’
methods We have a list object, pets, followed by a dot (.), followed by the method (function) call. EX: pets.append(‘guinea pig’) The list method append() is called on the list object pets with string input ‘guinea pig’.
Python Standard Library Consists of thousands of functions and classes organized into components called modules that relate to particular application domain. More than 200 built-in modules together form the Python Standard Library.
Module math To use a math module function >>> import math sqrt(x) ceil(x) (i.e., the smallest integer = x) floor(x)(i.e., the largest integer = x) cos(x) cos(x) sin(x) sin(x) log(x, base) logbase(x) pi 3.141592653589793 e 2.718281828459045
Module fractions >>> import fractions >>> a = fractions.Fraction(3, 4) >>> b = fractions.Fraction(1, 2) As with other numbers, Fraction objects can be added, and the result is a Fraction object: >>> c = a + b >>> c Fraction(5, 4)
float vs fraction the range of values that float objects can store is limited The range of values representable with fractions.Fraction objects is much, much larger and limited only by the available memory expressions involving float values evaluate much faster
Created by: kbaldwin