Data Analytics

Logo R Notes
Python Notes
Julia Notes
R-Studio Notes
Jupyter Notebooks
External Notes
Creating Markdown
Contributions

Python Variables

Python Variables

Creating Variables:

One of the most powerful features of a programming language is the ability to manipulate variables. A variable is a name that refers to a value. An assignment statement creates new variables and gives them values.Unlike other programming languages, Python has no command for declaring a variable.A variable is created the moment you first assign a value to it.For example

        x = 10
        y = "Laxmi"
        print(x)
10
        print(y)
Laxmi

As shown in example, the variable x holds the value 10 and y holds the word “Laxmi”.

Variables do not need to be declared with any particular type and can even change type after they have been set.

        x = 4 # x is of type int
        print(x)
4
    x = "Sally" # x is now of type str
    print(x)
Sally

As we see in the previos example, initially the x was as interger type but afterwards changed to String type.

Variabe Name

Programmers generally choose names for their variables that are meaningful and document what the variable is used for.A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables are as below:

Always remember that the variables are case sensitive.

Variable Type

The data stored in memory can be of many types. For example, a person’s age is stored as a numeric value and his or her address is stored as alphanumeric characters. Python has various standard data types that are used to define the operations possible on them and the storage method for each of them.

Python has five standard data types.These are listed as below:

For video tutorials for the variables and data type plese follow the link here as https://www.youtube.com/watch?v=OOvzRzS_eZs