1
00:00:05,060 --> 00:00:09,300
Alright, so make sure you've got the Hello World project open from the previous video,

2
00:00:09,300 --> 00:00:12,900
and opened in your IDE. In my case, of course, we're using IntelliJ.

3
00:00:12,900 --> 00:00:15,960
And I'm just going to double click this
helloworld.py tab,

4
00:00:15,960 --> 00:00:20,040
to give us the full screen, and we're going to try and do that in the course, but you may or may not want to do that.

5
00:00:20,040 --> 00:00:24,300
depending on the amount of screen real estate you've got, and whether you want to have the project pane open.

6
00:00:24,300 --> 00:00:29,200
So at the moment we've got a very simple program, that just prints out the text Hello World!

7
00:00:29,200 --> 00:00:34,560
There's a few important things to know about the code, and I've already mentioned that print is a function.

8
00:00:34,560 --> 00:00:40,140
When you call a function in Python, you provide the things you want to print inside parentheses.

9
00:00:40,140 --> 00:00:44,840
So we've provided a string literal, Hello World!, and that's what got printed.

10
00:00:44,840 --> 00:00:47,700
A string literal is a sequence of characters,

11
00:00:47,700 --> 00:00:52,280
anything you can type on the keyboard, basically, enclosed in quotes.

12
00:00:52,280 --> 00:00:56,420
You can use either a single quote or double quotes to enclose a string.

13
00:00:56,420 --> 00:01:00,600
I used single quotes but you could use
double quotes if you wanted to.

14
00:01:00,600 --> 00:01:03,500
It's important, though, to use the same ones, though.

15
00:01:03,500 --> 00:01:08,960
So if you start a string with double quotes, then it has to be terminated with a double quote.

16
00:01:08,960 --> 00:01:14,660
So if I change my single quote, on the end of Hello World, to a double quote,

17
00:01:14,660 --> 00:01:16,760
suddenly we've got an error there.

18
00:01:16,760 --> 00:01:19,500
You can't start with one style of quote and end with the other.

19
00:01:19,500 --> 00:01:23,260
You have to use the same type, at the start and at the end.

20
00:01:23,260 --> 00:01:28,180
So I'm going to fix the error by just doing a ctrl Z on my keyboard,

21
00:01:28,180 --> 00:01:33,860
twice to undo the change and go back to what we had before, which was a single quote at the end.

22
00:01:33,860 --> 00:01:40,140
And if I run it again, we've got no errors and we're getting the same output we got in the previous video.

23
00:01:40,140 --> 00:01:44,500
So when you've done that for the first time, as we did in the previous video, then again just now,

24
00:01:44,500 --> 00:01:47,300
IntelliJ remembers which program you want to run.

25
00:01:47,300 --> 00:01:51,700
Now in the drop down on the menu, in the right top of the screen, you can see it's going to run Hello World,

26
00:01:51,700 --> 00:01:56,300
it's showing is that, and you can use the green triangle icon, just to the right of that drop-down

27
00:01:56,300 --> 00:02:00,040
to run the same program again.
So I can come over and click on that

28
00:02:00,040 --> 00:02:03,180
So as you work through the course,
you'll have several files open at once.

29
00:02:03,180 --> 00:02:08,919
If you run them, using this green triangle icon, check that you're running the program that you expect.

30
00:02:08,919 --> 00:02:12,580
I'll talk about it again later,
when we've got more than one file open.

31
00:02:12,580 --> 00:02:16,660
Alright, so you saw me use the green triangle to the right of the Hello World text there,

32
00:02:16,660 --> 00:02:21,460
the drop down to run the program again,
we got the same output as we did previously.

33
00:02:21,460 --> 00:02:27,440
Alright, so a bit more jargon now. The string literal "Hello World!" is called an argument,

34
00:02:27,440 --> 00:02:29,840
at least in the context of what we're doing here.

35
00:02:29,840 --> 00:02:33,300
We're passing the argument to the print function.

36
00:02:33,300 --> 00:02:36,160
Functions can take more than one argument,

37
00:02:36,160 --> 00:02:41,600
and we'll be looking at how to define those when we write our own functions, later in the course.

38
00:02:41,600 --> 00:02:48,960
So we're passing a string argument to the print function, but we could also print, for example, the result of calculations.

39
00:02:48,960 --> 00:02:52,080
So let's go ahead and add some calculations.

40
00:02:52,080 --> 00:02:56,200
So I'm going to press ENTER there, I'm going to type print

41
00:02:56,200 --> 00:03:02,380
left parenthesis, and there's the right one automatically, and in the parentheses I'm going to type 1 + 2.

42
00:03:02,380 --> 00:03:09,480
Then on the next line i'm going to type print, add my parentheses and add  7 * 6.

43
00:03:09,480 --> 00:03:15,320
On the next line I'm just going to type print, and have left and right parentheses with nothing in there.

44
00:03:15,320 --> 00:03:21,680
Then on the line 5, the last one, I'm going to put print and parentheses again, double quotes this time.

45
00:03:21,680 --> 00:03:30,680
I'm going to type The end. Alright, so let's run this,

46
00:03:30,680 --> 00:03:33,820
and move this up a little bit, the run window, so we can see the output.

47
00:03:33,820 --> 00:03:39,520
So you can see that now that we've done that, Python works out the result of our arithmetic expressions,

48
00:03:39,520 --> 00:03:45,480
and it prints the answers; 1 + 2 is obviously 3,  7 * 6 is obviously 42.

49
00:03:45,480 --> 00:03:49,500
Now printing with left and right parentheses without telling Python what to print,

50
00:03:49,500 --> 00:03:52,900
just produces a blank line, and you can see that blank line there.

51
00:03:52,900 --> 00:03:56,300
We still need the parentheses, even though we're not providing an argument.

52
00:03:56,300 --> 00:04:00,440
When calling a function, you must have parentheses after the function name,

53
00:04:00,440 --> 00:04:04,040
and finally the program finishes after we're printing the string The end.

54
00:04:04,040 --> 00:04:07,360
Functions often take a specific number of arguments,

55
00:04:07,360 --> 00:04:12,340
but it's also possible to write functions that can take a variable number of arguments.

56
00:04:12,340 --> 00:04:15,640
The print function that's built into Python has been written that way.

57
00:04:15,640 --> 00:04:18,800
What that means is, we can print several things at once.

58
00:04:18,800 --> 00:04:23,620
So let's change the last line to print several strings and a number.

59
00:04:23,620 --> 00:04:29,680
So I'm going to put my cursor at the end of the double quote, after "The end".

60
00:04:29,680 --> 00:04:34,740
I'm gonna put a comma there, double quotes "or is it?"

61
00:04:34,740 --> 00:04:39,000
I'm going to move on after the double quotes again, comma

62
00:04:39,000 --> 00:04:47,780
I'm going to type "Keep watching to learn more about Python", and a double quote and comma

63
00:04:47,780 --> 00:04:51,900
then a number 3, making sure that's all in our parentheses.

64
00:04:51,900 --> 00:04:55,340
If we run the program now,

65
00:04:55,340 --> 00:04:59,500
you can see now that we've got 3 strings and a number printed on that line.

66
00:04:59,500 --> 00:05:03,480
So each argument is separated from the previous one with a comma.

67
00:05:03,480 --> 00:05:06,960
We're passing four arguments on this line, to print.

68
00:05:06,960 --> 00:05:12,500
So the first argument is "The end", and that's followed by a comma to separate it from the second argument,

69
00:05:12,500 --> 00:05:13,920
or is it?

70
00:05:13,920 --> 00:05:19,760
Once again, we need a comma before we provide the third argument, "Keep watching to learn more about Python",

71
00:05:19,760 --> 00:05:27,380
and the final argument is the numeric literal 3, which is also separated from the previous argument with a comma.

72
00:05:27,380 --> 00:05:32,560
Alright, so there's still a few more things to learn about the print function, and I'll be coming back to it in later videos.

73
00:05:32,560 --> 00:05:38,100
For now, we've learnt enough to be able to print from our programs, to check that they produce the correct results.

74
00:05:38,100 --> 00:05:44,900
Now I've introduced quite a few jargon words there, so let's finish this video with a slide to summarize them.

75
00:05:44,900 --> 00:05:54,340
So a literal, well that's a value of some type. An example of a numeric literal are the numbers 1, 42 and 98.04,

76
00:05:54,340 --> 00:05:56,460
and an example of a string literal

77
00:05:56,460 --> 00:06:01,440
are "Hello World!", "Giudo van Rossum" and "Python", all in quotes, as you can see there.

78
00:06:01,440 --> 00:06:06,280
Moving on, a function, well that's a named block of code that we can call by using its name.

79
00:06:06,280 --> 00:06:10,840
We can write our own functions, or we can use functions that are built into Python,

80
00:06:10,840 --> 00:06:13,500
such as we've been doing here, with the
print function.

81
00:06:13,500 --> 00:06:16,900
In Python, all functions return a value.

82
00:06:16,900 --> 00:06:21,840
Argument: a value passed to a function, in order to give it values to work with.

83
00:06:21,840 --> 00:06:25,220
Now there may be no arguments, or there may be one or more.

84
00:06:25,220 --> 00:06:28,800
Arguments appear in parentheses, after the function name.

85
00:06:28,800 --> 00:06:33,980
If there are no arguments, you still have to type in the left and right parentheses.

86
00:06:33,980 --> 00:06:38,500
Calling a function: using the function name to execute the function's code.

87
00:06:38,500 --> 00:06:43,460
When you call a function, you have to provide the arguments that the function expects.

88
00:06:43,460 --> 00:06:48,020
If it doesn't expect any arguments, don't
put anything between the parentheses.

89
00:06:48,020 --> 00:06:51,940
Return value: well that's the value that a function returns.

90
00:06:51,940 --> 00:06:56,500
We haven't talked about that yet, but it belongs in this slide to make the slide complete.

91
00:06:56,500 --> 00:07:01,560
So more on that later, and parameter, also called a formal parameter.

92
00:07:01,560 --> 00:07:03,620
This is something else we haven't discussed yet,

93
00:07:03,620 --> 00:07:07,420
and we'll learn about parameters when we start writing our own functions.

94
00:07:07,420 --> 00:07:10,040
Alright, so let's end the video here. In the next one,

95
00:07:10,040 --> 00:07:12,180
we're gonna start talking about strings.

96
00:07:12,180 --> 00:07:15,020
See you in the next video.

