Getting started - Python objects, basic types, and variables
Getting started - Python objects, basic types, and variables#
Everything in Python is an object and every object in Python has a type. Some of the basic types include:
int(integer; a whole number with no decimal place)10-3
float(float; a number that has a decimal place)7.41-0.006
str(string; a sequence of characters enclosed in single quotes, double quotes, or triple quotes)'this is a string using single quotes'"this is a string using double quotes"'''this is a triple quoted string using single quotes'''"""this is a triple quoted string using double quotes"""
bool(boolean; a binary value that is either true or false)TrueFalse
NoneType(a special type representing the absence of a value)None
In Python, a variable is a name you specify in your code that maps to a particular object, object instance, or value.
By defining variables, we can refer to things by names that make sense to us. Names for variables can only contain letters, underscores (_), or numbers (no spaces, dashes, or other characters). Variable names must start with a letter or underscore.