Python – types of variables

Alright, so today I learnt there are 4 types of variables which can be assigned. Assigning a variable is using the Equal (=) to assign any value.

Variables can only start with letters or an underscore (_), starting with numbers are invalid.

Examples

string1 = “Hello World”

integer1 = 200

float1 = 203.1

The example is for Integer type

You can try it this way too.

The boolean data type can have one of two values, True or False. We use an assignment operator = to assign a boolean value to variables in a manner similar to what we have seen for integer and float values.

Example

TimeisPrecious = True

TimeisMoney = False

print(TimeisPrecious)

It will give you True.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s