1
00:00:02,060 --> 00:00:04,160
Hoping that you are enjoying the videos.

2
00:00:04,190 --> 00:00:12,080
Let's start with the very first video on this series of revisions reviewing the basics of Python.

3
00:00:15,840 --> 00:00:17,940
So I'll be showing you coats here.

4
00:00:19,410 --> 00:00:21,810
And you have two choices.

5
00:00:21,810 --> 00:00:27,990
Either you can just watch these videos without doing anything, or you can start a passion project and

6
00:00:27,990 --> 00:00:31,740
then write the code either in that P files.

7
00:00:33,320 --> 00:00:35,930
Or just use an interactive python console.

8
00:00:38,410 --> 00:00:39,250
On my end.

9
00:00:39,250 --> 00:00:45,010
I have placed the code already in something called Jupyter Lab.

10
00:00:45,580 --> 00:00:49,900
So what you're looking at is a tool called Jupiter Lab.

11
00:00:50,470 --> 00:00:54,370
In Jupiter lab, you can write in code and execute it both.

12
00:00:54,370 --> 00:00:57,010
That is something that you learn in day 30.

13
00:00:58,070 --> 00:01:02,840
So Jupiter Lab is good for presenting out code to other people.

14
00:01:02,840 --> 00:01:07,760
So for now, you don't really need Jupiter lab, so please focus on Python code.

15
00:01:09,610 --> 00:01:09,910
Right.

16
00:01:09,910 --> 00:01:13,780
Let's start with the first concept objects and variables.

17
00:01:15,210 --> 00:01:21,690
So we have two main topics and these topics have subtopics so objects can be stored in variables.

18
00:01:21,720 --> 00:01:28,080
Writes John is an object, Smith is an object, and this number here is also an object.

19
00:01:28,530 --> 00:01:30,990
All these are strings, actually.

20
00:01:30,990 --> 00:01:36,780
So everything that is wrapped in double quotes is a string, even when that is a number.

21
00:01:37,200 --> 00:01:39,600
So these are actually real numbers.

22
00:01:39,600 --> 00:01:42,990
This is an integer and this is a float.

23
00:01:42,990 --> 00:01:52,290
Now you'd ask, How do I know when to use codes on a number and when to use the number without quotes?

24
00:01:52,290 --> 00:01:56,940
Well, the answer is that if that number has mathematical meaning.

25
00:01:58,470 --> 00:02:02,420
Then you should use the number without quotes.

26
00:02:02,430 --> 00:02:10,770
But if that number will not be used in mathematical operations such as addition or multiplication,

27
00:02:10,770 --> 00:02:16,140
etc., such as is the case of the ID here, then it should be a string.

28
00:02:18,000 --> 00:02:25,530
So all these here, all these objects drawn and five and 1.75 are stored in variables.

29
00:02:26,850 --> 00:02:28,230
But sometimes.

30
00:02:31,780 --> 00:02:35,200
Objects can be produced by functions.

31
00:02:36,110 --> 00:02:45,110
For example, we have this variable here, and this variable is associated with the call of the input

32
00:02:45,110 --> 00:02:45,860
function.

33
00:02:47,800 --> 00:02:55,330
So when this input function is called, when it's executed, then the user will enter a string, for

34
00:02:55,330 --> 00:02:55,810
example.

35
00:02:55,810 --> 00:02:56,500
Or did.

36
00:02:57,800 --> 00:03:02,180
This string will be stored in that name variable.

37
00:03:02,190 --> 00:03:04,460
So this is indirectly.

38
00:03:04,580 --> 00:03:10,280
In this case we stored the objects directly in the variables and here is indirect.

39
00:03:10,280 --> 00:03:16,190
So when we call that variable, when we print it out or you just call it in the interactive shell,

40
00:03:16,190 --> 00:03:18,800
you should get something like this.

41
00:03:20,850 --> 00:03:24,360
So that's the string that was stored in the name variable.

42
00:03:25,570 --> 00:03:30,610
Sometimes, though, you have to be careful with types.

43
00:03:31,600 --> 00:03:33,550
Let's see this other example.

44
00:03:35,740 --> 00:03:40,270
This is asking the user to enter the hearts so the user enters the height.

45
00:03:41,710 --> 00:03:44,620
And then this height is stored as a string.

46
00:03:44,620 --> 00:03:51,430
So this is not what you might want here, because this has some mathematical meaning.

47
00:03:51,430 --> 00:03:55,240
It could be subtracted or added to another number.

48
00:03:55,660 --> 00:03:57,790
So in that case.

49
00:03:58,920 --> 00:04:05,400
You can use converters such as a float or int.

50
00:04:06,600 --> 00:04:09,870
So in this case, this is the same code as this.

51
00:04:09,870 --> 00:04:15,720
But in addition, we have this float with parentheses here and parentheses there.

52
00:04:16,589 --> 00:04:20,899
So whatever the user enters here, that will be converted into a float.

53
00:04:20,910 --> 00:04:25,080
As you can see here, name is one 75.0.

54
00:04:27,990 --> 00:04:32,640
So that brings us to the next topic, which is functions.

55
00:04:32,730 --> 00:04:34,200
So that was a function.

56
00:04:34,590 --> 00:04:36,120
Input was a function.

57
00:04:36,450 --> 00:04:38,160
Print is also function.

58
00:04:38,160 --> 00:04:41,280
Now not all functions return a value.

59
00:04:41,310 --> 00:04:43,830
This is something that you really should understand.

60
00:04:45,020 --> 00:04:51,380
For example, the print function does not return a value, right?

61
00:04:51,800 --> 00:04:59,000
So in the case of the input function here or here.

62
00:05:01,120 --> 00:05:06,670
The input function returns a value which was 175.

63
00:05:06,850 --> 00:05:15,250
That value is stored in the name variable, but some functions such as the print function does not return

64
00:05:15,250 --> 00:05:15,910
a value.

65
00:05:15,910 --> 00:05:16,360
Right?

66
00:05:16,360 --> 00:05:22,900
So in x, if you print out x, you'll get nothing because there is nothing stored in x.

67
00:05:23,680 --> 00:05:31,660
This, however, doesn't mean that the function isn't doing anything, so the function might still be

68
00:05:31,660 --> 00:05:33,340
executing some procedures.

69
00:05:33,340 --> 00:05:37,120
For example, printing out some texts on the command line.

70
00:05:37,420 --> 00:05:37,960
Right.

71
00:05:38,260 --> 00:05:38,850
As is.

72
00:05:38,880 --> 00:05:40,180
As is the case here.

73
00:05:40,900 --> 00:05:43,030
But don't confuse that with.

74
00:05:44,060 --> 00:05:46,370
The returned output.

75
00:05:47,470 --> 00:05:50,080
Let's take another example with custom functions.

76
00:05:50,080 --> 00:05:56,860
So that is a function which you can create, and this particular function is indeed returning a value.

77
00:05:56,860 --> 00:06:05,740
So this function is basically similar to the input function in that it returns a value and the value

78
00:06:05,740 --> 00:06:08,380
is returned with this return keyword.

79
00:06:08,410 --> 00:06:16,540
So when you do foo, so the name of the function, when you call that function and you associate it

80
00:06:16,540 --> 00:06:21,580
with a variable in x, you will store whatever you return in here.

81
00:06:21,580 --> 00:06:23,380
So x will be equal to ten.

82
00:06:23,920 --> 00:06:31,000
But if you write another function definition which doesn't have a return statement.

83
00:06:34,430 --> 00:06:36,170
So no return statement here.

84
00:06:36,200 --> 00:06:43,550
And then you call the function and you try to store the output in x, then x will have nothing associated.

85
00:06:44,900 --> 00:06:52,280
Well, in some terminals, in some consults, perhaps you get a non printed out, which is some kind

86
00:06:52,280 --> 00:06:52,880
of value.

87
00:06:52,880 --> 00:06:55,930
Actually, it's a kind of object type.

88
00:06:55,940 --> 00:06:58,180
Like we have strings, we have numbers.

89
00:06:58,190 --> 00:07:04,910
This is also a type of value, but it means that it's a nothing value.

90
00:07:08,340 --> 00:07:13,410
So make sure to return a value if you want the function to give some output.

91
00:07:14,250 --> 00:07:19,410
So that brings us to the issue of return versus print.

92
00:07:20,070 --> 00:07:31,290
So this function here for one has this value variable declaration, and then it returns that value.

93
00:07:31,290 --> 00:07:32,730
It should be value, not ten.

94
00:07:32,730 --> 00:07:35,520
So it returns ten basically.

95
00:07:38,970 --> 00:07:43,830
And this function here, instead of returning it prints out the value.

96
00:07:49,470 --> 00:07:52,410
Now to understand the difference between that and that.

97
00:07:52,440 --> 00:07:54,060
You should call the function.

98
00:07:54,060 --> 00:07:55,800
So let's call the first function.

99
00:07:55,800 --> 00:08:01,320
For one, we store its output in x one and x one will be equal to ten.

100
00:08:01,320 --> 00:08:01,650
Right?

101
00:08:01,650 --> 00:08:12,210
Because it returns this value here which has a value of ten while x two is equal to four two.

102
00:08:13,260 --> 00:08:21,240
And no notice that if you do this, the function through two is being called, and when the function

103
00:08:21,240 --> 00:08:28,710
is called print is executed, that means you will get an output when the function is called.

104
00:08:28,740 --> 00:08:32,919
However, in here we didn't get an output when foo one was called.

105
00:08:32,940 --> 00:08:39,419
You don't get an output because there is no print function here inside this function, so nothing will

106
00:08:39,419 --> 00:08:40,289
be printed out.

107
00:08:41,820 --> 00:08:47,220
However, the difference is that the first function will store a value.

108
00:08:48,330 --> 00:08:55,890
In x one, you see x one will be ten, but x two here will be equal to nothing.

109
00:08:56,980 --> 00:08:57,240
Right?

110
00:08:57,240 --> 00:09:00,060
So that is the difference between return and print.

111
00:09:02,700 --> 00:09:05,370
Functions can have parameters.

112
00:09:05,430 --> 00:09:08,910
So these functions here didn't have any parameters.

113
00:09:08,910 --> 00:09:17,190
So the parentheses are empty, but this one here gets a parameter and it processes.

114
00:09:18,800 --> 00:09:22,370
That's parameter and it returns some results.

115
00:09:24,340 --> 00:09:25,240
And then.

116
00:09:26,710 --> 00:09:30,880
You can call that function by giving a value to that.

117
00:09:31,730 --> 00:09:35,240
Parameter or now you can call it an argument.

118
00:09:35,900 --> 00:09:42,050
So when we're talking about the function definition, we usually refer to that as a parameter.

119
00:09:42,050 --> 00:09:45,490
But then in the function call, we refer to that as the argument.

120
00:09:45,500 --> 00:09:50,240
So a number is the argument and ten is the value of the argument.

121
00:09:50,930 --> 00:09:52,700
So the function will get the value.

122
00:09:52,700 --> 00:09:54,080
Ten It will.

123
00:09:54,990 --> 00:10:00,960
Do ten times ten 100, and it will return 100.

124
00:10:01,110 --> 00:10:03,510
So 100 will be stored in x.

125
00:10:03,510 --> 00:10:05,220
So x is 100.

126
00:10:10,160 --> 00:10:17,240
Now, this here was a function called with an argument name, and this year is also a function called

127
00:10:17,240 --> 00:10:19,070
but without the argument name.

128
00:10:22,560 --> 00:10:26,010
So these two produce the same results.

129
00:10:26,490 --> 00:10:29,100
But the way you declare the argument changes.

130
00:10:29,100 --> 00:10:32,130
So it's just a change in the style of the code.

131
00:10:32,160 --> 00:10:35,580
The functionality doesn't change.

132
00:10:35,970 --> 00:10:37,680
Which one should you use?

133
00:10:38,880 --> 00:10:46,980
Well, both have their advantages and disadvantages, so this year tends to be a bit more readable because

134
00:10:46,980 --> 00:10:50,520
you know that ten is the number arguments.

135
00:10:50,520 --> 00:10:57,570
So you know what ten is and this year is shorter, so it's cleaner.

136
00:10:58,620 --> 00:11:02,010
So you have to choose between shorter codes and cleaner codes.

137
00:11:04,140 --> 00:11:09,450
And usually if it's clear what arguments you are passing to a function.

138
00:11:11,660 --> 00:11:15,680
For example, if this was a function that says calculate.

139
00:11:17,780 --> 00:11:18,830
Square.

140
00:11:18,860 --> 00:11:24,530
Then you know that this function is calculating the square of a number so you can just pass ten and

141
00:11:24,530 --> 00:11:27,500
you know that you are calculating the square of ten.

142
00:11:29,140 --> 00:11:30,910
So that's the idea here.

143
00:11:34,120 --> 00:11:40,810
Then we have functions with multiple arguments so you can pass multiple parameters in the function definition

144
00:11:40,840 --> 00:11:46,840
divided by commas, and then you can call those parameters, those arguments.

145
00:11:46,840 --> 00:11:54,070
Again, you can either do number one is equal to ten or number two is equal to 20.

146
00:11:55,640 --> 00:11:59,360
Or you can just pass the values without the argument names.

147
00:11:59,450 --> 00:12:08,750
But be aware that if you pass the argument values only, you should respect the the older of the parameters.

148
00:12:10,310 --> 00:12:14,900
So ten will go to number one and 20 will go to number two.

149
00:12:19,330 --> 00:12:19,940
Right.

150
00:12:19,960 --> 00:12:22,480
Functions with default parameters.

151
00:12:24,070 --> 00:12:26,640
So this here is a default parameter.

152
00:12:26,650 --> 00:12:27,940
It has.

153
00:12:28,870 --> 00:12:35,590
A default value, which means that when you call that function, which is what we're doing here.

154
00:12:37,690 --> 00:12:40,870
And you are okay with that argument.

155
00:12:40,870 --> 00:12:47,590
Having that default value, which is true in this case, then you don't have to pass that argument in

156
00:12:47,590 --> 00:12:48,610
the function call.

157
00:12:52,170 --> 00:12:57,390
But if you want to pass that argument, then you can do so as I've done it here.

158
00:12:57,840 --> 00:12:58,440
Right.

159
00:13:00,590 --> 00:13:04,750
That was own objects and variables and functions.

160
00:13:04,790 --> 00:13:06,960
In the next video, let's talk about methods.

161
00:13:06,980 --> 00:13:07,600
See you there.

