Earn 20 XP


  • A variable can be considered as a storage container for data.

  • Every variable will have a name.

  • It is a good way to store information while making it easy to refer to that information in our code later.

image.png

  • For instance, instead of working with the number 3.14, we can assign it to a variable pi and use it as many times as we want in our code (wherever required).

  • The equal sign (=) is used to assign values to variables.

  • The syntax for assigning values to a variable is as follows: Variable name = value or information.

  • Example:

    • x = 5
    • y = "John"