﻿1
00:00:00,330 --> 00:00:04,900
‫Now let's move on to strings and python.

2
00:00:05,110 --> 00:00:14,190
‫So how can we pass a string in a python if I just write as the python tutorial and executed

3
00:00:21,370 --> 00:00:31,480
‫I'm getting an error because we need to pass strings and double quotes or single chords so we can write

4
00:00:32,410 --> 00:00:35,620
‫double chords as deep Python tutorials

5
00:00:42,920 --> 00:00:43,500
‫here.

6
00:00:43,540 --> 00:00:45,540
‫We use double quotation marks.

7
00:00:45,580 --> 00:00:53,290
‫You can also use single quotes to pass a string but sometimes your string may contain single quotes

8
00:00:53,370 --> 00:00:54,650
‫in between.

9
00:00:54,670 --> 00:00:58,780
‫So therefore it is recommended to use double quotes while passing the strings

10
00:01:01,610 --> 00:01:02,860
‫just like numbers.

11
00:01:02,870 --> 00:01:12,080
‫We can also assign this thing to some variable so we can write SB one here SDR one is over variable

12
00:01:12,320 --> 00:01:15,050
‫and we are assigning value asleep by tend to Dodi Al

13
00:01:25,580 --> 00:01:31,790
‫no my SDR 1 variable contains this value.

14
00:01:31,830 --> 00:01:40,770
‫Now if we want to display the value of our SDR one variable I will just write SDR one and then execute

15
00:01:40,800 --> 00:01:42,270
‫this Come on.

16
00:01:42,510 --> 00:01:50,430
‫You can see we are getting our output and you can also notice that at speed by 10 tutorial is coming

17
00:01:50,430 --> 00:01:52,900
‫in quotation marks.

18
00:01:53,010 --> 00:02:01,810
‫There is also a separate print function and button to print the output to print output will write print

19
00:02:03,670 --> 00:02:06,850
‫and in brackets will write SDR 1

20
00:02:10,690 --> 00:02:18,350
‫you can now notice that there is no quotation marks and now the values are printed and they are not

21
00:02:18,350 --> 00:02:20,600
‫a part of 0 4.

22
00:02:20,720 --> 00:02:26,540
‫You can see when we just executed as earlier when we were getting the content of this variable in the

23
00:02:26,540 --> 00:02:27,710
‫form of output.

24
00:02:27,770 --> 00:02:30,260
‫You can see this output returning it.

25
00:02:30,530 --> 00:02:34,100
‫But when we are printing it by then is actually printing it.

26
00:02:34,100 --> 00:02:35,720
‫And this is not a part of our

27
00:02:38,950 --> 00:02:46,650
‫Python even provides formatting options with this print function so suppose I wanted to use some variable

28
00:02:47,250 --> 00:02:56,250
‫inside my brain come on I can do that by using green formatting for example and then what previous example

29
00:02:57,510 --> 00:03:05,350
‫in the phrase as deep Python tutorial I wanted to pass variable X which will take value by 10 or are

30
00:03:05,500 --> 00:03:07,120
‫depending the value

31
00:03:12,560 --> 00:03:20,870
‫so if my axis python I wanted to print as true by standard Oriel if my X is odd I wanted to print as

32
00:03:20,870 --> 00:03:31,950
‫the r tutorial or if X is a school I wanted to print as B and school tutorial so let's create this variable

33
00:03:31,980 --> 00:03:34,910
‫X and assign it value add

34
00:03:38,060 --> 00:03:43,950
‫notice that we are using double quotes to assign value to this variable

35
00:03:47,170 --> 00:03:48,580
‫we will first rate print

36
00:03:52,230 --> 00:04:03,420
‫and then records will put quotation marks and will pass the update string which is s.t. and then since

37
00:04:03,510 --> 00:04:13,120
‫I won my second word too with this variable X I will I will give complete records and my third word

38
00:04:13,270 --> 00:04:15,180
‫is upon strength which is tutorial.

39
00:04:15,520 --> 00:04:20,820
‫So I will write tutorial.

40
00:04:21,580 --> 00:04:25,880
‫Now I want to tell python what goes inside this go live record.

41
00:04:26,290 --> 00:04:36,490
‫So after this print come on I will put a dot and write format and in parenthesis I can write my variable

42
00:04:36,490 --> 00:04:38,770
‫name which is X

43
00:04:42,530 --> 00:04:51,750
‫let's run this we are getting this edit because dot format should be inside the print come on.

44
00:04:51,750 --> 00:04:54,290
‫So we just copy paste it

45
00:05:00,620 --> 00:05:01,030
‫yeah.

46
00:05:01,150 --> 00:05:11,240
‫And now if we execute it you can see we are getting as the odd tutorial if I change my value of x to

47
00:05:11,880 --> 00:05:13,650
‫skew it.

48
00:05:14,700 --> 00:05:25,780
‫And then again then this spring come on you can see no sense of what X is askew in the output is segment

49
00:05:25,790 --> 00:05:29,130
‫based SD is squarely custodian.

50
00:05:29,410 --> 00:05:35,770
‫So what's happening here is the live record in print come on titles Python to take the value of variable

51
00:05:35,950 --> 00:05:45,300
‫that is mentioned in the dot format parenthesis if I want I can also pass toward more than two variables.

52
00:05:45,300 --> 00:05:48,110
‫This index will remain the same in that case.

53
00:05:49,200 --> 00:05:55,260
‫And you have to mention the variable names and not form it in the order you want them to be filled in

54
00:05:55,260 --> 00:05:56,120
‫the college record.

55
00:05:57,700 --> 00:05:59,620
‫So if we just write print

56
00:06:03,310 --> 00:06:06,160
‫and index it we'll write s.t.

57
00:06:10,630 --> 00:06:16,800
‫then college records yet our variable X will come then after this tutorial

58
00:06:20,140 --> 00:06:21,600
‫and then another can leave record

59
00:06:25,940 --> 00:06:36,770
‫and in dot we can write X and the variable we created earlier that was very when if we executed this

60
00:06:38,630 --> 00:06:47,430
‫you can see what where one variable was containing 14 so what printed string it a city school tutorial

61
00:06:47,430 --> 00:06:54,550
‫for being now let's discuss some important functions related to strings.

62
00:06:54,570 --> 00:06:58,250
‫The first function is land function.

63
00:06:58,250 --> 00:07:04,300
‫It helps us to find the length of our string the syntax of Len.

64
00:07:04,440 --> 00:07:06,010
‫Function as a.

65
00:07:06,140 --> 00:07:16,070
‫And now if we want to check the length of our we one variable we can just mention SDR one inside parenthesis

66
00:07:16,130 --> 00:07:18,150
‫after length.

67
00:07:18,510 --> 00:07:28,270
‫You can see the length of our variable as are one is 18 also known that is spaces also character so

68
00:07:28,270 --> 00:07:40,280
‫this length 18 is count of all the characters including spaces and the penetration marks as well another

69
00:07:40,290 --> 00:07:46,260
‫string function which we frequently used is replaced function.

70
00:07:46,350 --> 00:07:53,700
‫You must have used replace function involved or not bank where you search the word and then replace

71
00:07:53,700 --> 00:07:58,710
‫that word with a new word replace function and by Python bucks.

72
00:07:58,710 --> 00:08:00,840
‫Exactly the same.

73
00:08:00,950 --> 00:08:02,360
‫You have to give two words

74
00:08:04,960 --> 00:08:06,910
‫first the word you want to search.

75
00:08:06,970 --> 00:08:09,940
‫And second the vote you want to replace it with.

76
00:08:11,430 --> 00:08:14,700
‫So let's again print over SDR one variable

77
00:08:18,150 --> 00:08:19,170
‫right now.

78
00:08:19,170 --> 00:08:29,970
‫My SDR 1 contains a steep Python tutorial if I want to replace this word python with as school I will

79
00:08:29,970 --> 00:08:45,580
‫write SB 1 not replace and then record for the word I want to replace that is Python.

80
00:08:45,690 --> 00:08:48,250
‫Also remember that Python is case sensitive.

81
00:08:48,260 --> 00:08:56,710
‫Language so I have to pass python in lowercase since my variable contains python and lowercase i want

82
00:08:56,710 --> 00:08:59,470
‫to replace this variable with a script.

83
00:09:00,550 --> 00:09:03,670
‫So after a comma I will write a script.

84
00:09:09,870 --> 00:09:20,130
‫You can see that the word by 10 has now been replaced with a school I can also save this value in another

85
00:09:20,130 --> 00:09:20,570
‫variable.

86
00:09:21,540 --> 00:09:25,080
‫So let's see if this value in another variable called X

87
00:09:30,600 --> 00:09:33,750
‫I will copy paste so function

88
00:09:41,090 --> 00:09:42,060
‫if I bring Dex

89
00:09:45,410 --> 00:09:47,530
‫and you get this value as the school.

90
00:09:47,550 --> 00:09:50,380
‫Claudia.

91
00:09:50,540 --> 00:09:56,330
‫Now let's move on to a string indexes and string slicing.

92
00:09:56,350 --> 00:10:01,120
‫You can see a string is a collection of several individual characters.

93
00:10:01,120 --> 00:10:11,820
‫For example in our variable X as is a single character B is a single character and our whole string

94
00:10:11,940 --> 00:10:15,540
‫is a collection of such characters.

95
00:10:15,620 --> 00:10:20,240
‫This characters are present at a specified position they know what a string.

96
00:10:20,240 --> 00:10:29,300
‫So for example as is present at the first politician B is present at the second position.

97
00:10:29,510 --> 00:10:32,930
‫And similarly we have a space and the third position

98
00:10:36,030 --> 00:10:42,840
‫we can extract this individual characters from our variable by specifying their positions.

99
00:10:42,840 --> 00:10:50,700
‫This concept of extracting characters by their position is known this string indexing of all is String

100
00:10:50,760 --> 00:10:52,680
‫slicing.

101
00:10:53,040 --> 00:10:58,920
‫One thing to note here is that in Python indexing starts with zero

102
00:11:02,180 --> 00:11:13,130
‫so a word character as is presented 0 to index B is present at first index and space is presented to

103
00:11:13,190 --> 00:11:21,600
‫index so if I want to extract the character which is present at the first index I will just straight

104
00:11:21,600 --> 00:11:25,950
‫up what a variable name which is x and then a squared record.

105
00:11:25,950 --> 00:11:27,960
‫I will mention the index which is 1

106
00:11:32,970 --> 00:11:43,870
‫if we execute this we will get B as I would output since B was present at the first index position is

107
00:11:43,870 --> 00:11:51,180
‫different from index the position of B is two but since the index starts from 0 0 it as was presented

108
00:11:51,180 --> 00:11:54,670
‫C both index and nobody was present at first index

109
00:11:57,520 --> 00:12:00,050
‫I can also mention multiple index.

110
00:12:00,220 --> 00:12:09,760
‫So if I want all the characters which are present from index to the index 5 I will write X and then

111
00:12:09,760 --> 00:12:19,960
‫a squared record I will write to and then I will provide the colon symbol and then I will write 5.

112
00:12:20,030 --> 00:12:29,530
‫This means that I want all characters which are present between index 2 and 5 notice that our first

113
00:12:29,530 --> 00:12:35,570
‫character is a space where the second character is as another third character is skewed.

114
00:12:37,830 --> 00:12:47,400
‫We are getting all the characters that are present at index 2 index 3 and index for we are not getting

115
00:12:48,060 --> 00:12:57,090
‫our index 5 variable because the second argument is always excluded while slicing the string using indexes

116
00:12:58,550 --> 00:12:59,530
‫so too.

117
00:12:59,530 --> 00:13:05,410
‫Column 5 means character presented index 2 3 and 4

118
00:13:08,840 --> 00:13:18,230
‫similarly if we write X bracket for colon 6 it will return the characters which are present at index

119
00:13:18,230 --> 00:13:30,440
‫4 and 5 index 6 will be excluded from all the selection indexes also supports negative argument negative

120
00:13:30,630 --> 00:13:39,110
‫it for counting from the backside of this string so minus 1 will be the last character of string minus

121
00:13:39,110 --> 00:13:42,200
‫2 will be the second last character and so on.

122
00:13:44,150 --> 00:13:50,920
‫So if I wanted to print last character off my string I will write X and end in a square record.

123
00:13:51,020 --> 00:13:53,270
‫I will mention minus 1

124
00:13:58,130 --> 00:14:04,650
‫we are getting L as our output since the last character it all forward very well.

125
00:14:04,660 --> 00:14:06,030
‫X was an

126
00:14:10,150 --> 00:14:11,250
‫while slicing.

127
00:14:11,260 --> 00:14:25,030
‫You can also skip the arguments so if I write X and squared record I will write colon 5.

128
00:14:25,110 --> 00:14:31,410
‫This means that I want all the characters from the start off my string line next 5.

129
00:14:31,440 --> 00:14:32,220
‫If I add on this

130
00:14:36,110 --> 00:14:40,470
‫you can see we are getting all the characters from the start of this string.

131
00:14:40,490 --> 00:14:49,880
‫Similarly if I want all the characters from index 5 to the end of the string I would write X and record.

132
00:14:49,880 --> 00:14:51,410
‫I would like five colon

133
00:14:54,820 --> 00:15:00,000
‫can see all the characters from the fifth index is present in our output

134
00:15:03,190 --> 00:15:05,740
‫now votive if I wanted done it.

135
00:15:05,740 --> 00:15:13,830
‫Characters from my string I can do that by mentioning the third parameter which is the step that I make.

136
00:15:14,520 --> 00:15:17,620
‫So earlier we were passing on the two parameters.

137
00:15:17,880 --> 00:15:25,820
‫The starting point and then after the colon we were passing the end point we can also pass the Turk

138
00:15:25,850 --> 00:15:29,600
‫argument after another colon symbol as a step argument.

139
00:15:31,250 --> 00:15:37,670
‫So if I write X and then squared record I will write to colon then

140
00:15:41,280 --> 00:15:49,950
‫this means I want all the characters from index to index 9 remember index expense is excluded.

141
00:15:52,490 --> 00:16:04,400
‫But if I write to colon 10 colon 2 this means I want characters with a step as 2 so I will be getting

142
00:16:04,490 --> 00:16:11,310
‫characters presented indexed to and since our step is still pretty radically jumped to index for

143
00:16:14,290 --> 00:16:26,910
‫and then to index 6 and then to index it fight on this if I bring my X just to compare our output.

144
00:16:27,440 --> 00:16:35,020
‫You can see our character at index 2 was space

145
00:16:38,580 --> 00:16:53,110
‫character at index for was Q then character at index 6 was again in space and then character at index

146
00:16:53,230 --> 00:16:54,460
‫it was you

147
00:16:57,820 --> 00:17:04,140
‫similarly if you want to take this step size 2 3 4 or anything you can do that

148
00:17:08,010 --> 00:17:16,580
‫1 think you may have noticed is that we are not defining variables while creating the variables as with

149
00:17:16,580 --> 00:17:23,510
‫the other programming languages such as C askew L or C++ we don't have to define variable types and

150
00:17:23,510 --> 00:17:33,270
‫by 10 by 10 will automatically assign the type depending on the value present in that variable so if

151
00:17:33,270 --> 00:17:42,090
‫you are passing variable X as one by 10 will automatically assign X as an integer if you are passing

152
00:17:42,390 --> 00:17:52,550
‫X as on a string it will automatically assign X as a string or if passing it as a decimal point it will

153
00:17:52,550 --> 00:18:01,100
‫get a floating point type to know the type of variable we can use type function we just have to write

154
00:18:01,100 --> 00:18:09,470
‫type and in parentheses write the variable name but here we will write X and we should get a string

155
00:18:09,590 --> 00:18:21,120
‫as our output you can see the type of of what variable x is SBA similarly figured the type of forward

156
00:18:21,410 --> 00:18:22,820
‫variable that is

157
00:18:25,690 --> 00:18:26,530
‫variable 1

158
00:18:29,310 --> 00:18:34,830
‫we are getting and since our variable 1 was containing 14 as a value

159
00:18:38,810 --> 00:18:47,690
‫now if we assign variable to a value of five divided by two and we print this really way too you can

160
00:18:47,690 --> 00:18:56,950
‫see that variable 2 is taking a value 2.5 if we want to get the tape of this variable 2 we will write

161
00:18:56,960 --> 00:19:05,720
‫type and then record will write variable 2 we should be adding floating number as decimal is spelt in

162
00:19:05,720 --> 00:19:06,320
‫our value.

