VARIABLES IN PYTHON

Unlike other programming language, Declaring variable in python is very easy, In python variable is created at the moment you assign a value to it. And variable can be of any data type.

Example:v1

Variable can be of any data type.v2

Rules for Variable Names

A variable can have a short name (like x and y) or a more descriptive name (age, name, sum, volume). Rules for Python variables:

  • A variable name must always start with a letter or the underscore character(_)
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (age, Age and AGE are three different variables)

In Python you can use + operator to combine to variable names of same data type.

v3

2.)

v4

3.)

v5

4.)Python will give an error when you try to combine a string with integer:

v6

Leave a comment