1
00:00:00,740 --> 00:00:07,950
So let's start by creating a function that turns these kind of strings into this form.

2
00:00:08,090 --> 00:00:08,810
Define.

3
00:00:11,450 --> 00:00:17,350
Let's call this sentence_maker() so it makes the sentences out of raw strings.

4
00:00:17,480 --> 00:00:19,270
Let's call these strings phrases.

5
00:00:19,300 --> 00:00:20,800
OK phrase.

6
00:00:20,870 --> 00:00:22,300
So it gets a phrase.

7
00:00:22,350 --> 00:00:25,950
And first you want to capitalize that phrase.

8
00:00:25,960 --> 00:00:26,300
Right.

9
00:00:27,980 --> 00:00:32,290
So maybe create a valuable insight that function called it's capitalized.

10
00:00:32,480 --> 00:00:40,210
Or wherever you like and say phrase and use the capitalized method

11
00:00:40,310 --> 00:00:50,210
of strings and in the meantime you can use your Python interactive shell to try out methods to see how they

12
00:00:50,210 --> 00:00:55,260
work while you at the same time create a function in your editor.

13
00:00:55,790 --> 00:01:07,730
So for example let's say I want to capitalize this string. First I'd like to try out how the capitalized method

14
00:01:07,730 --> 00:01:08,830
works.

15
00:01:08,870 --> 00:01:14,460
So now I'm sure that it's capitalizes a first letter so that's fine.

16
00:01:14,580 --> 00:01:22,670
Now we want to add to concatenate a period or a question mark to these phrases.

17
00:01:22,670 --> 00:01:22,990
Right.

18
00:01:23,600 --> 00:01:25,300
But that depends.

19
00:01:25,320 --> 00:01:31,760
And so we are talking about a condition here, the program has to make a decision whether to put a period

20
00:01:31,850 --> 00:01:40,680
or a question mark at the end of the phrase so let's go ahead and build a condition. If phrase...

21
00:01:40,780 --> 00:01:45,120
So how can we differentiate between questions and simple sentences

22
00:01:45,160 --> 00:01:49,060
that end with a period. Well, there may be different ways there.

23
00:01:49,180 --> 00:01:53,770
So that depends on the programmer and how sophisticated you want to do that.

24
00:01:53,800 --> 00:02:01,240
But let's keep it simple and let's say that questions are all those that start with an interrogative

25
00:02:01,450 --> 00:02:04,270
words such as how why and what.

26
00:02:04,390 --> 00:02:10,390
And you can check that with let's say you have a sentence like "how are you".

27
00:02:10,390 --> 00:02:20,870
Again. You can use the starts with method which gets a tuple as input.

28
00:02:20,870 --> 00:02:25,070
So a tuple, and inside that tuple you can have

29
00:02:28,250 --> 00:02:35,910
some strings that you're checking if this sentence starts with any of the strings inside this tuple.

30
00:02:35,930 --> 00:02:40,200
So let's say how, what, and why.

31
00:02:42,320 --> 00:02:45,110
So that will return true.

32
00:02:45,110 --> 00:02:49,780
Because how are you starts with one of these strings.

33
00:02:50,180 --> 00:03:00,500
In another scenario like "it's a good whether", you'll get false, so we can make use of that and say if phrase

34
00:03:01,040 --> 00:03:02,870
starts with

35
00:03:09,060 --> 00:03:14,180
how, what, and why.

36
00:03:14,910 --> 00:03:22,650
You can do that or even better would be to get this tuple and save it in a variable.

37
00:03:26,470 --> 00:03:27,640
Let's say interrogatives.

38
00:03:27,910 --> 00:03:28,870
And put it there.

39
00:03:28,870 --> 00:03:34,790
So then here you just put the variable and that will make the code more readable.

40
00:03:35,020 --> 00:03:43,700
So if the phrase starts with interrogatives, what we want to do in this case is to construct a string

41
00:03:45,010 --> 00:03:50,780
so let's say you return, the function will return this string.

42
00:03:50,920 --> 00:03:52,210
So that is

43
00:03:56,780 --> 00:04:05,630
capitalized, so capitalized will be capitalized version of the phrase that the user enters.

44
00:04:05,810 --> 00:04:13,580
And then we want to add to that a question mark just like that.

45
00:04:13,710 --> 00:04:17,850
So that will be replaced by capitalized by that string.

46
00:04:18,000 --> 00:04:20,220
And that will add a question mark to that.

47
00:04:20,220 --> 00:04:27,940
So that will happen if the phrase starts with any of the interrogative else return,

48
00:04:28,080 --> 00:04:34,540
in this case we will return a sentence with a dot, with a period.

49
00:04:35,340 --> 00:04:38,400
Again capitalized is what we put here.

50
00:04:39,600 --> 00:04:43,230
Let me demonstrate so far what we have.

51
00:04:43,440 --> 00:04:44,700
Sentence maker.

52
00:04:44,910 --> 00:04:50,220
So we want to execute the function, right? 
With a word, with a phrase.

53
00:04:50,220 --> 00:04:51,090
"How are you"?

54
00:04:53,980 --> 00:04:55,460
Save.

55
00:04:56,070 --> 00:04:57,030
Execute.

56
00:04:57,080 --> 00:04:59,930
And so we get the sentence correctly.

57
00:04:59,940 --> 00:05:00,520
How are you?

58
00:05:01,580 --> 00:05:02,370
That's it.

59
00:05:02,370 --> 00:05:06,270
Now we have a function that does something and does it good.

60
00:05:06,630 --> 00:05:10,410
Let's now think about the other aspects of the program in the next video.

