How Can We Help?
< All Topics
Print

Python Types

Numeric Types and Finding the Type of an Object:

Python has a variety of basic variable types, and we have already seen a few! See some further examples below. The type function can indicate an object or variable’s type.

An extension of the integer type is the boolean type. Booleans store true/false values as integers (1 for true, 0 for false). In Python, booleans use the following notation:

To convert between types, you can cast a variable using the following notation:

String Types:

string is a sequence of alphanumeric characters:

Accents and Unicode characters are supported but may cause issues with string functions if not handled carefully.

A u in front of a string designates it as Unicode. You can copy Unicode characters to use to set a variable like this:

Or you can define Unicode characters using an escape sequence. Here ‘\u4f60’ refers to 你.

Table of Contents