1 00:00:00,500 --> 00:00:06,180 Python variables and constraints, we shall start with our discussion with Python variables. 2 00:00:06,500 --> 00:00:10,130 We know that in any programming language we define some variables. 3 00:00:10,340 --> 00:00:14,370 So variables are nothing but some named memory locations. 4 00:00:14,690 --> 00:00:21,230 So how many memory locations will be defined under one variable that will be decided by its dictate? 5 00:00:21,440 --> 00:00:23,180 That is a side of that data. 6 00:00:24,020 --> 00:00:26,250 So here we are having the python variables. 7 00:00:26,390 --> 00:00:29,640 So in Python Biddable is a name name. 8 00:00:29,670 --> 00:00:33,080 The location used to store data in the memory. 9 00:00:33,410 --> 00:00:37,170 Each variable must have a unique name called identified. 10 00:00:37,460 --> 00:00:44,150 So depending upon the data type of the variable, the number of bytes going to be occupied, that will 11 00:00:44,150 --> 00:00:51,380 be decided and the memory address of that memory block will be having a name which is accessible from 12 00:00:51,380 --> 00:00:52,450 the programming code. 13 00:00:52,580 --> 00:00:59,480 So that will make the programmers it will make the programmers easier to write their goals in Python. 14 00:00:59,480 --> 00:01:02,900 Variables do not need declension to resolve memory space. 15 00:01:03,170 --> 00:01:09,890 The variable declension or the variable initialization happens automatically when we assign available 16 00:01:10,220 --> 00:01:11,990 assign a value to a variable. 17 00:01:12,260 --> 00:01:18,470 So there is no need to define all the variables at the beginning of the code, like in our C C++, we 18 00:01:18,470 --> 00:01:23,660 always write all the variables and the respective negatives at the beginning of our code and then only 19 00:01:23,660 --> 00:01:27,500 we can use them in the respective successive codes. 20 00:01:27,650 --> 00:01:30,170 But that constraint is not there in Python. 21 00:01:30,560 --> 00:01:36,320 That variable declaration and the variable initialization can be done in the same statement. 22 00:01:36,770 --> 00:01:40,010 So here you see this account is equal to one hundred. 23 00:01:40,250 --> 00:01:50,120 The underscore name is Robyn and say H1, H2 is three is equal to 44, comma 37, comma 22. 24 00:01:50,240 --> 00:01:56,180 So in this way, you see at this particular line, the variable age one is two, three, they are defined. 25 00:01:57,230 --> 00:02:03,980 Their respective vegetables have got initialised and here you see here we put the integer value so the 26 00:02:03,980 --> 00:02:07,240 we will have their respective little type integer in that case. 27 00:02:07,610 --> 00:02:14,570 So in this way, we can have multiple variables, can be initialized, can be can be declared in the 28 00:02:14,570 --> 00:02:15,500 same statement. 29 00:02:15,590 --> 00:02:17,750 And there is a syntax in which we are right. 30 00:02:18,200 --> 00:02:22,280 So there is no need to put the semicolon at the end of the Python statement. 31 00:02:22,290 --> 00:02:24,040 So that's why no semicolon is there. 32 00:02:24,260 --> 00:02:29,240 So that's why this is a way to define and also to initialize variables. 33 00:02:30,760 --> 00:02:38,740 He constantly is a type of vegetable whose value cannot be changed, and it is helpful to think of Constance 34 00:02:38,860 --> 00:02:43,850 as containers that hold information which cannot be changed later on. 35 00:02:44,050 --> 00:02:48,190 So that's why the constant is not but available, which will be holding a value. 36 00:02:48,190 --> 00:02:50,590 But the value cannot be changed later on. 37 00:02:51,130 --> 00:02:54,970 So naming conventions for variables and constants in Biocon. 38 00:02:55,180 --> 00:02:58,100 So that is that nomenclature should be purposeful. 39 00:02:58,450 --> 00:03:04,240 We all know that it is a good program aspect is the best practices of the developers and programmers. 40 00:03:04,240 --> 00:03:10,150 Is that the variable name, the function name, the class name should be purposeful hamdard very variable 41 00:03:10,150 --> 00:03:10,440 name. 42 00:03:10,450 --> 00:03:15,610 I should get the idea what is the purpose of the variable and what kind of value it is supposed to hold 43 00:03:16,420 --> 00:03:17,620 that use name. 44 00:03:17,800 --> 00:03:19,360 There is a camel case notation. 45 00:03:19,420 --> 00:03:24,190 What is the meaning of this since the first letter will be in the lowercase. 46 00:03:24,310 --> 00:03:25,480 But the next two words. 47 00:03:25,480 --> 00:03:30,130 If there are multiple words in the variable name, they'll be starting with the capital letters and 48 00:03:30,130 --> 00:03:32,230 the rest of the letters will be in the lowercase. 49 00:03:32,710 --> 00:03:38,170 So use capital letters to the present are constant symbols like you're at the root of hash. 50 00:03:38,290 --> 00:03:42,720 Exclamation dollard percentage should not be used. 51 00:03:43,120 --> 00:03:47,180 Don't start with the digit that is very common in the previous video. 52 00:03:47,180 --> 00:03:54,340 Also, we are showing you that one one variable is not a valid variable name, but variable one is a 53 00:03:54,340 --> 00:03:55,330 valid variable name. 54 00:03:55,720 --> 00:04:02,340 So constants are put into function models and meant to be meant not to be changed to I. 55 00:04:02,440 --> 00:04:06,220 As I discussed earlier, though, constants cannot be changed later on. 56 00:04:06,640 --> 00:04:12,150 So constant and variable names should have the combination of letters in lowercase that is small a too 57 00:04:12,160 --> 00:04:20,380 small Z or uppercase letters that is a capital A to capital Z are digits that is to nine or an underscore. 58 00:04:20,740 --> 00:04:23,770 These are the valid characters in naming. 59 00:04:24,130 --> 00:04:31,540 So let us go for further discussion with some demonstration for easier understanding in decision. 60 00:04:31,540 --> 00:04:38,290 We are discussing and demonstrating how to define constants and variables so constants in Python can 61 00:04:38,290 --> 00:04:38,950 be defined. 62 00:04:38,950 --> 00:04:44,380 It is a common practice to write all the constraint, the constant name, all in the capital letters. 63 00:04:44,680 --> 00:04:48,430 So physical two three point four gravity is equal to nine point eight. 64 00:04:48,430 --> 00:04:51,760 In this way, the constants can be defined in our python. 65 00:04:52,180 --> 00:04:54,040 And now we are going to define that. 66 00:04:54,040 --> 00:05:01,180 How that variables can be defined and how to declare variable, how to assign valid values on them so 67 00:05:01,180 --> 00:05:02,210 is equal to Apple. 68 00:05:02,230 --> 00:05:06,400 So now it is available as the apple is up to type text or string. 69 00:05:06,400 --> 00:05:08,320 So it be up to type string here. 70 00:05:08,890 --> 00:05:11,350 So print a so I'll get printed. 71 00:05:11,360 --> 00:05:13,090 So now let's go for the execution. 72 00:05:13,090 --> 00:05:14,740 This line has got no print, so. 73 00:05:14,740 --> 00:05:15,280 That's right. 74 00:05:15,700 --> 00:05:17,140 No, no outcome is there. 75 00:05:17,140 --> 00:05:19,240 So let me go for that print. 76 00:05:22,490 --> 00:05:27,350 If you go for the sprint by we're getting this one and been one for now for this part. 77 00:05:27,380 --> 00:05:29,840 If I go for the execution, it will come like this. 78 00:05:31,060 --> 00:05:37,750 So is the apple so pretty, so it is printing Apple here, changing the value of available so that can 79 00:05:37,750 --> 00:05:39,370 be done using reassignment. 80 00:05:39,700 --> 00:05:41,710 So easy go to Aeroplan. 81 00:05:41,740 --> 00:05:45,630 So now if you type this one and then print it, it is printing their respective string. 82 00:05:46,300 --> 00:05:49,900 So next time I'm printing, I'm just assigning 100 to it. 83 00:05:49,930 --> 00:05:53,590 So now if we print it, then it is getting the value 100. 84 00:05:53,660 --> 00:05:58,210 So you're going to find that the same biddable sometimes may be initialized with the string, sometimes 85 00:05:58,210 --> 00:06:04,090 with the integer, and that is allowed in Python because in case of Python, Python, Python is a dynamic 86 00:06:04,090 --> 00:06:08,830 type language that means the variables will be decided during the runtime. 87 00:06:09,280 --> 00:06:15,310 So during the runtime, whatever the value the variable is containing, that will decide the fate of 88 00:06:15,310 --> 00:06:15,460 them. 89 00:06:15,880 --> 00:06:19,180 And in case of Python, there is no need to declare the variable separately. 90 00:06:19,180 --> 00:06:25,870 At the beginning of the code, we can define variable as when we request to use them and he can find 91 00:06:25,870 --> 00:06:26,620 that here. 92 00:06:26,620 --> 00:06:28,360 This is Aeroplane's. 93 00:06:28,360 --> 00:06:33,520 So that means that EA has got the data type string and the next part of the code that will be treated 94 00:06:33,520 --> 00:06:37,420 as a string until unless it is getting initialized with some other data type. 95 00:06:38,230 --> 00:06:40,550 So here we ablated is equal to 100. 96 00:06:40,570 --> 00:06:46,870 So the next part of the code will be treated as the type integer until unless is getting initialized 97 00:06:46,870 --> 00:06:50,730 with some other type of Pelosse assigning multiple values to be available. 98 00:06:50,740 --> 00:06:57,640 So B, C, D, all these three variables are getting assigned with this one, 2.5 Penhallow respectively 99 00:06:57,640 --> 00:06:59,360 in a single single line. 100 00:06:59,710 --> 00:07:04,030 So this one will be assigned to be 2.5, will be assigned to C and will be assigned to. 101 00:07:04,570 --> 00:07:09,530 So when you are printing B, C and D, we're getting the outcome as one two point five. 102 00:07:09,760 --> 00:07:10,610 And hello. 103 00:07:11,320 --> 00:07:16,810 Next one, is that assigning the same value to multiple variables, using a same statement in the same 104 00:07:16,810 --> 00:07:22,040 line, you know, so B is able to see is the D is equal to fight. 105 00:07:22,420 --> 00:07:29,050 That was if I was getting assigned to B, C and D, but at the same time in a single segment, single 106 00:07:29,050 --> 00:07:29,980 assignment STATMAN. 107 00:07:30,160 --> 00:07:32,560 So Phi Phi Phi is going to get printed here. 108 00:07:33,190 --> 00:07:39,280 So in this example and demonstration, we have discussed that how to define constants and how to define 109 00:07:39,280 --> 00:07:41,740 variables and how to assign values on them. 110 00:07:42,340 --> 00:07:43,570 Thanks for watching this video.