What is meant by variable in python?Give suitable example.
What is meant by variable in python?
507
28-Mar-2023
Aryan Kumar
18-Apr-2023Basically, variable is a name that is used to refer to a value stored in the computer's memory. Variables are used to store data that can be used later in a program, and they can store different data types such as strings, numbers, or lists.
In python, creating or declaring a variable is so easy as compared to other programing languages. In other programing languages you need to declare variable as well as data type also. But in python you simply declare a variable as follows:
variables can be updated or reassigned with a new value anytime in the program by simply assigning a new value to thee variable.
Krishnapriya Rajeev
28-Mar-2023In Python, a variable is a name that refers to a value or object stored in the computer's memory. It is used to store data, which can be of any type such as numbers, strings, lists, dictionaries, or objects. We also need to follow certain naming conventions when creating a variable.
The naming convention for variables is as follows:
a) Camel Case - The first letter of each word except the first is made capitalized.
Eg: mindStick
b) Snake Case - Words are separated using underscores. Eg: mind_stick
c) Pascal Case - Each word starts with a capital letter Eg: MindStick
To assign a value to a variable in Python, you simply use the equals sign (=) and write the variable name on the left side of the equals sign and the value you want to assign to it on the right side.
Example:
Above shown are 3 variables of type integer, string, and boolean respectively.