Data Types

View Notebook

Every value has a type, and the built-in type function returns the type of the result of any expression.

type(3)
int
type(3/1)
float

The type of an expression is the type of its final value. So, the type function will never indicate that the type of an expression is a name, because names are always evaluated to their assigned values.

x = 3
type(x) # The type of x is an int, not a name
int

Another type we have encountered already is a built-in function. Python indicates that the type is a builtin_function_or_method; the distinction between a function and a method is not important at this stage.

type(abs)
builtin_function_or_method

This chapter will explore other useful types of data.

results matching ""

    No results matching ""