 Hello friends, I am Naval Yamal working as the Assistant Professor in Mechanical Engineering Department, Walsh and Institute of Technology, Solapur. In this video, we are going to see variables, data types, and numbers in Python. Learning outcomes. At the end of this session, students will be able to understand about variables, what are different types of data types, and numbers used in Python. First, we will see what are Python variables. So if you want to create a variable that is creating a variable, variables are containers for storing data values. Unlike other programming language, Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. For example, if I put x equal to 5 and y equal to John, print x and y, so it automatically takes that x is an integer and y as a string. So no need to mention or no need to declare a variable like other programming language. So output would be 5 and John. Variables do not need to be declared with any particular type and can even change the type after they have been set. For example, x equal to 4, that is x is a type of integer. And if I write x equal to Sally, now x is a type of string. If I print x, so that has been changed from integer to string. The output would be Sally. Variables can be declared either by using single or double quotes. For example, x double quote John is the same as x equal to single quote John. So the output would be John. Variable names, a variable can have a short name like x and y or a more descriptive names like age, car name, total volume, etc. The rules for Python variables. A variable name must start with a letter or the underscore character. A variable name cannot start with a number. A variable name can only contain alphanumeric characters and underscores like a to z 0 to 9 and underscore. Variable names are case sensitive, age and capital A G E and all capital H are three different variables. So Python is a case sensitive. So these are the rules of the Python. Before you declare a variable, you need to look at these rules. Assign value to multiple variables. Python allows you to assign values to multiple variables in one line. For example, x, y, z are three different variables. X is assigned to orange, y for banana and z, z for cherry. And if I print x, y, z, the output would be orange, banana and cherry. And you can assign the same value to multiple variables in one line. For example, x, y and z all are equal to orange. And if I print x, y, z, the output would be orange, orange and orange. Output variables. The Python print statement is often used to output variables to combine both text and variable Python uses plus characters. For example, x equal to awesome. And if I want to print Python is awesome, what I'll do Python print Python is plus x. X is nothing but awesome. So the final output will be Python is awesome. You can also use the character to add variable to another variable. For example, x is a variable and in x it is Python is and in y is awesome. And if I take third variable z and if I want to add these two strings that is x plus y, print z, the output would be Python is awesome. For numbers, the plus characters work as a mathematical operator, which we have already seen in the first video, x equal to 5, y equal to 10. If I want to print x plus y, the output would be 15. So pause the video for few seconds and think if we combine string and number, what will be the output? Okay, so let us try if we combine string and number, what will be the output in Python? If I take x equal to 5 and y equal to John, and if I want to add a string with integer, so the output will be the error because it cannot add two different types. String and integer cannot be added, so it shows the error unsupported operand. So you need to be clear that before adding, the operand should be same, the data type should be same. Next we are going to see Python data types. So there are many inbuilt data types. In programming, data type is very important concept. Variables can store data of different types and different types can do different things. Python has a following data type built in by default in these categories. So in numeric type, there are basically three main type of data types that is int, float and complex. In sequence types, it is least, tuple and range. Mapping type, we have dictionary, DICT, set types that is set, frozen set, and boolean type that is boole. And there are many types of data types we will be covering in the next videos. Getting the data type, you can get the data type of any object by using type function. We have seen this in the first video, we will see few examples here. Suppose if x equal to 5, if I want to know the data type here, so the function would be print type x, so the output would be class integer. Setting the data type, the data type is set when you assign a value to a variable. Suppose x equal to hello world is a string type, 20 is an integer, 20.5 is a float and 1j is a complex. If you want to specify the data type, you can use the following constructor functions like you need to say string hello world, it becomes the data type would be a string, int 20, float 20.5 and complex 1j. So we will see what are Python numbers. There are three numeric types in Python, int, float and complex. Examples of numeric types are created when you assign a value to them, x equal to 1 is integer, y equal to 2.8 is float and 1j would be a complex. And if you want to check the type of x, y and z, the function would be print type x and followed by y and z. The output would be class int, so the first is class integer, then class float, then complex. Integer or integer, int is a whole number positive or negative without decimals of unlimited length. If I put x equal to and y equal to 3, 5, 6, 5, 6, 2, 2 and so on and z equal to minus and if I print the type, it all shows the integer. The same way float, float is a floating point number, a decimal number, 1.10, 1.0, this all would be the type of float. Then you have complex where j is an imaginary part, here you have two parts real and imaginary part and if you want to check the type of this, the function would be type x, y and z, the output would be complex type conversion. You can convert from one type to another with the int, float and complex methods. For example, if you want to convert one type to another, suppose x is in integer 1 and it is y is in float 2.8 and complex z equal to 1j. Convert from int to float, so float, just you need to write a function like float of x, so x would be converted into float and y float to integer and integer to complex. So if I print this all and the type, you would get the output like from integer, it has moved to float and from float to integer and from complex integer is moved to complex. So float, integer and complex. If you want to generate any random number in Python, so you have a function inbuilt called random that can be used to make a random numbers. So it displays any number between 1 to 9, so the function would be import, you need to import this from the Python library random. Then print random.rand range from 1 to 10, so you get output, any number from 1 to 10, I got 6. So these are the references I have used, thank you.