• Variables

    In programming, variables are used to store data values. These values can be of different data types, such as strings, integers, floating-point numbers, boolean, arrays, or objects. Variables are assigned names so that they can be referenced in the code. They can be any size and shape, and can hold anything from numbers to strings of text. You can use variables to keep track of things like user input, or the result of a calculation. The name of a variable can be anything you want, as long as it doesn’t start with a number and isn’t a reserved word in the language. Once a variable is given a value, that value can be changed throughout the program by reassigning the variable. Variables are one of the most important tools in programming, and understanding how to use them is essential to becoming a good programmer.

      • String Variables

      • A string variable is simply a variable that can hold multiple pieces of text (a word, phrase, or sentence). However, sometimes we need to store more than just text. We might want to store a person's name, which can be multiple words. In this case, we need to use a string variable.

      • Integer Variables

      • An integer variable is a data type in computer programming that stores numerical values. Integer variables can be used to represent whole numbers, such as 1, 2, 3, 4, 5, etc. They can also be used to represent negative numbers, such as -1, -2, -3, -4, -5, etc. Integer variables are commonly used in programs to store counts or loop indices.

      • Float Variables

      • Float variables, like integer variables, hold numerical values but are presented in decimal form. It is possible to represent decimal numbers such as 1.01, 2.20, 3.33, 4.44, 5.555, etc. in float variables. They can also be used to represent negative decimal numbers, such as -1.01, -2.20, -3.33, -4.44, -5.555, etc.

      • Boolean Variables

      • A boolean variable is a type of data that can only have one of two possible values, either true or false. In programming, boolean variables are often used to track whether a certain condition has been met, or to control the flow of a program. For example, a program might use a Boolean variable to keep track of whether a user is logged in or not.

      • Array Variables

      • Array variables are used in many programming languages to store data sets of various sizes. An array is a type of data structure that stores a collection of elements. Each element in the array has a specific index, which can be used to access it.

      • Object Variables

      • An object variable is a type of variable that is used to reference an object. The value of an object variable is an address that identifies the location of the object in memory. When an object is assigned to an object variable, a new reference to the object is created. An object is a type of data structure that holds a collection of properties and methods. For each property and method, a name is used to access them.

      • class Person:
        	def __init__(self, name, age):
        		self.name = name
        		self.age = age
        	def greet(self):
        		print('Hello my name is ' + self.name)
        human = Person('John', 36)
        print(human.name)  # John
        print(human.age)  # 36
        human.greet()  # Hello my name is John