Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,250 --> 00:00:02,050
Hey, guys.
2
00:00:02,060 --> 00:00:03,230
And welcome back.
3
00:00:03,260 --> 00:00:08,400
In this section, we'll be focusing on some key concepts of Python programming.
4
00:00:08,420 --> 00:00:13,460
Variables, comments built in data types and operators.
5
00:00:13,610 --> 00:00:16,309
Let's start off with variables.
6
00:00:16,400 --> 00:00:17,840
What is a variable?
7
00:00:17,840 --> 00:00:22,310
How to declare a variable and how to use variables in Python.
8
00:00:23,180 --> 00:00:27,920
A variable is one of the fundamental concepts of any programming language.
9
00:00:28,100 --> 00:00:30,820
We use variables to store the data.
10
00:00:30,830 --> 00:00:37,640
The application is working with a variable is nothing more than a label or a name for a memory.
11
00:00:37,640 --> 00:00:42,440
Location where a value which can be manipulated is stored.
12
00:00:43,260 --> 00:00:46,620
To be more concise, I'd like to give you a simple example.
13
00:00:46,830 --> 00:00:53,190
Let's suppose you develop a simple script that converts miles to kilometers.
14
00:00:54,780 --> 00:00:59,550
When running the script, it will ask for the number of miles.
15
00:00:59,730 --> 00:01:07,860
Then the user will enter a value, let's say ten, and the script will give the corresponding value
16
00:01:07,860 --> 00:01:12,030
in kilometers, which is 16.9.
17
00:01:12,660 --> 00:01:18,480
By the way, one mile equals 1.69 kilometers.
18
00:01:19,570 --> 00:01:22,690
The value ten entered by the user.
19
00:01:23,350 --> 00:01:28,570
Will be saved by the program in a variable somewhere in the memory.
20
00:01:28,750 --> 00:01:31,780
To be more precise, in the RAM memory.
21
00:01:31,810 --> 00:01:34,630
All variables are saved in RAM memory.
22
00:01:35,110 --> 00:01:41,440
So we can define a variable is a name for a memory, location or address that stores the value.
23
00:01:41,470 --> 00:01:50,500
In our example, then a variable has a name and is the variable word implies the value stored in it
24
00:01:50,530 --> 00:01:51,640
can be changed.
25
00:01:52,850 --> 00:01:55,580
I'm creating a new Python script in picture.
26
00:02:01,360 --> 00:02:08,710
In Python, you can simply create a new variable by typing the variable name, the equal sign in the
27
00:02:08,710 --> 00:02:11,600
value that will be stored in the variable.
28
00:02:11,620 --> 00:02:14,110
For example, miles equals ten.
29
00:02:15,560 --> 00:02:19,970
This creates a variable named Miles that stores the value ten.
30
00:02:20,790 --> 00:02:25,620
The variable was created the moment you first assigned a value to it.
31
00:02:26,940 --> 00:02:35,250
Now, if you want to modify the value stored in the miles variable, you write miles the equal sign
32
00:02:35,250 --> 00:02:37,590
and the new value, for example, 15.
33
00:02:39,180 --> 00:02:46,620
We won't go into details now, but we'll have a long discussion about immutable and immutable variables,
34
00:02:46,620 --> 00:02:51,870
which means what happens with the variable when we change the value stored in it.
35
00:02:53,450 --> 00:03:00,800
You can also declare multiple variables on a single line like this one comma, B, comma C equals one,
36
00:03:00,800 --> 00:03:02,000
comma two, comma three.
37
00:03:03,080 --> 00:03:06,920
And I'm printing a B.
38
00:03:08,400 --> 00:03:09,060
SC.
39
00:03:10,810 --> 00:03:16,840
By the way, print is a python function used to display messages onto the screen.
40
00:03:16,870 --> 00:03:24,340
You give it a variable or a message as an argument, and the function will display it on the screen.
41
00:03:24,670 --> 00:03:26,020
And I'm running the script.
42
00:03:27,610 --> 00:03:33,310
You can see the values of A, B, and C or H, Co my name equals.
43
00:03:34,410 --> 00:03:36,030
30 comic John.
44
00:03:37,720 --> 00:03:39,580
John in single quotes.
45
00:03:40,690 --> 00:03:50,950
I've created two variables a variable called edge that stores the integer value of 30 and another variable
46
00:03:50,950 --> 00:03:57,280
called name that stores a string or a sequence of characters with the value of John.
47
00:03:58,110 --> 00:04:04,290
By the way, if you add one or more species at the beginning of the line before the variable name,
48
00:04:04,290 --> 00:04:05,850
you will get a syntax error.
49
00:04:06,830 --> 00:04:11,360
This is a syntax error because I added a whitespace.
50
00:04:15,380 --> 00:04:22,580
Indentation is part of the syntax in Python and all instructions belonging to the same block of code
51
00:04:22,580 --> 00:04:24,380
should have the same indentation.
52
00:04:24,800 --> 00:04:29,480
Indentation refers to the spaces at the beginning of a code line.
53
00:04:30,220 --> 00:04:32,170
I'm removing the white space.
54
00:04:33,780 --> 00:04:41,140
Often you will see terms as defining a variable, declaring a variable or initializing a variable.
55
00:04:41,160 --> 00:04:47,700
In other programming languages, for example, in C or C++, there is a very clear distinction between
56
00:04:47,700 --> 00:04:50,430
declaring and defining a variable.
57
00:04:51,170 --> 00:04:57,090
The clearing means introducing a new name and type, for example, in miles.
58
00:04:58,080 --> 00:05:04,780
Which means a new variable called Miles will be created and it will store an integer value.
59
00:05:04,800 --> 00:05:09,400
And the defining means allocating a value to that variable.
60
00:05:09,420 --> 00:05:11,460
For example, miles equals ten.
61
00:05:13,530 --> 00:05:16,770
By the way, this is not valid Python code.
62
00:05:18,060 --> 00:05:18,990
In Python.
63
00:05:18,990 --> 00:05:26,640
We don't have such a distinction because we don't explicitly specify the type of data the variable will
64
00:05:26,640 --> 00:05:27,150
store.
65
00:05:28,150 --> 00:05:36,130
A variable is also sometimes simply called a name and can store any type of value, a whole number or
66
00:05:36,130 --> 00:05:42,840
integer, a floating point number, or simply a float or a sequence of characters or a string, a list,
67
00:05:42,850 --> 00:05:44,920
a reference to a file, and so on.
68
00:05:46,550 --> 00:05:48,510
Och, we are done for the moment.
69
00:05:48,530 --> 00:05:54,110
In this video we've learned what a variable is and how to declare a variable in Python.
70
00:05:54,140 --> 00:06:00,560
We'll take a short break and in the next video we'll go over naming conventions for variables.
6799
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.