1
00:00:01,000 --> 00:00:07,060
Hey, in this video, we will continue our Code Experiment series where we try to change things from

2
00:00:07,060 --> 00:00:09,520
the code and see how the output changes.

3
00:00:09,520 --> 00:00:14,020
So that gives you more understanding about how the code works.

4
00:00:15,180 --> 00:00:25,050
For this, I will create a new folder directory experiments, and then inside here I'll just create

5
00:00:25,050 --> 00:00:26,040
a python file.

6
00:00:28,090 --> 00:00:35,770
So the first experiment I wanted you to try is to just say, well, through and then print anything

7
00:00:35,770 --> 00:00:36,040
here.

8
00:00:36,040 --> 00:00:36,460
Such as?

9
00:00:36,460 --> 00:00:37,800
Hello, The string.

10
00:00:37,810 --> 00:00:38,380
Hello.

11
00:00:38,680 --> 00:00:47,020
Now, if I right click here and run this script, what I'll get is Hello, Print it out all the time,

12
00:00:47,680 --> 00:00:48,760
repeatedly.

13
00:00:49,300 --> 00:00:55,630
So nothing is stopping my computer from printing of this string over and over again.

14
00:00:57,370 --> 00:01:00,400
So why is Hallo printed out all the time?

15
00:01:00,610 --> 00:01:01,840
That's the first question.

16
00:01:01,840 --> 00:01:06,440
Well, it is being printed out because this is always true.

17
00:01:06,460 --> 00:01:12,250
So nothing is stopping this line from being executed over and over again.

18
00:01:13,390 --> 00:01:21,220
If the bonus example video which comes later today, you will see that we can write conditions which

19
00:01:21,220 --> 00:01:25,060
will change the behavior of the wild loop.

20
00:01:25,480 --> 00:01:30,040
So these conditions will control how many times the wild loop executes.

21
00:01:30,370 --> 00:01:34,720
But this loop here doesn't have such dynamic conditions.

22
00:01:35,020 --> 00:01:39,970
So the next question is how many times is this hello printed out?

23
00:01:40,450 --> 00:01:45,250
And the answer is, well, depends on your computer processor speed.

24
00:01:46,430 --> 00:01:54,670
So this would be about every X milliseconds or so, depending how able your processor is to receive

25
00:01:54,670 --> 00:01:56,720
the instructions and return the output.

26
00:01:58,090 --> 00:01:59,800
Another experiment.

27
00:02:00,730 --> 00:02:05,540
So let me put here the code that we wrote during the video tutorials earlier.

28
00:02:05,560 --> 00:02:09,370
This is the exact code that we have built so far in our app.

29
00:02:09,940 --> 00:02:19,970
Now, what would happen if we get this line and paste it inside the wild loop to cut a line in part

30
00:02:19,970 --> 00:02:20,350
charm.

31
00:02:20,350 --> 00:02:25,690
You can set the cursor anywhere in the line and then in your keyboard.

32
00:02:25,990 --> 00:02:28,270
Press control x.

33
00:02:29,110 --> 00:02:30,790
Or command X.

34
00:02:31,830 --> 00:02:33,410
That will cut the line.

35
00:02:33,420 --> 00:02:42,180
And then you go here, make a new line and press control V or command V, and that will place the line

36
00:02:42,180 --> 00:02:42,990
in there.

37
00:02:43,920 --> 00:02:51,570
So now the question is, is this version better or was that version with that line there better than

38
00:02:51,570 --> 00:02:52,200
this one?

39
00:02:53,460 --> 00:02:57,540
If you run this version of the code, it will work the same.

40
00:03:03,810 --> 00:03:05,460
So nothing is changing.

41
00:03:05,700 --> 00:03:10,800
But is it still a good way to program like this?

42
00:03:11,220 --> 00:03:12,300
The answer is no.

43
00:03:13,080 --> 00:03:20,160
And that is because it is not necessary to have the variable declaration inside the wild loop.

44
00:03:20,460 --> 00:03:28,650
So this variable declaration will be executed multiple times because it is inside a loop and that is

45
00:03:28,650 --> 00:03:29,550
not necessary.

46
00:03:29,550 --> 00:03:33,900
So that will simply make your program heavier.

47
00:03:34,350 --> 00:03:42,030
Even though a variable declaration does not occupy heavy resources, it's still not the best practice

48
00:03:42,120 --> 00:03:43,610
to program like this.

49
00:03:43,620 --> 00:03:48,180
So we only have to declare the string once.

50
00:03:48,210 --> 00:03:52,080
Therefore, I'll just put it where it was here.

51
00:03:52,350 --> 00:03:55,500
You don't need to execute that line multiple times.

52
00:03:55,920 --> 00:04:01,560
You only put in the wild loop things that will be executed in cycles.

53
00:04:02,640 --> 00:04:12,030
Another experiment Try to change capitalized with title and run the program and see how the output changes.

54
00:04:12,030 --> 00:04:18,570
Enter it to to clean the room and see what we got.

55
00:04:18,750 --> 00:04:24,690
Clean the room with the first letter of each word capitalized.

56
00:04:25,200 --> 00:04:30,630
So the capitalized methods only capitalized the first letter of the string.

57
00:04:30,630 --> 00:04:33,810
So only C was capitalized in the string.

58
00:04:33,810 --> 00:04:39,060
But the title method finds all the words and capitalizes the first letters.

59
00:04:39,480 --> 00:04:42,090
So that's just another method of strings.

60
00:04:42,360 --> 00:04:46,260
And now you might ask, How do you know all these methods?

61
00:04:46,290 --> 00:04:52,640
Well, I'll answer you that question today in the Programming Tool of the Day.

62
00:04:52,650 --> 00:04:58,800
So in that video later today, I'll show you the secret on how to find the list of all methods that

63
00:04:58,800 --> 00:05:03,270
you can apply to strings and other objects.

64
00:05:03,510 --> 00:05:05,340
So stay tuned for that video.

65
00:05:06,620 --> 00:05:08,550
Two more small experiments.

66
00:05:08,570 --> 00:05:16,310
If you remove print and you just say to do the title, as you might guess, if you enter it to do,

67
00:05:16,790 --> 00:05:20,870
you will not get any output because the print function is not there.

68
00:05:21,410 --> 00:05:27,110
So let's get the print function back and do our last experiment.

69
00:05:27,140 --> 00:05:34,820
If you remove these two parentheses here, the parentheses of the title method, if you remove that

70
00:05:34,820 --> 00:05:42,050
and you run the script, you clean the room and what you get is, is this output.

71
00:05:42,740 --> 00:05:46,580
So this is simply saying that this is a method.

72
00:05:47,240 --> 00:05:53,780
But in order to get the output that a method generates, you need to use those parentheses.

73
00:05:54,350 --> 00:05:56,900
So these are always necessary.

74
00:05:57,620 --> 00:06:02,030
Keep that in mind and thank you for following the code experiments for today.

75
00:06:02,060 --> 00:06:02,990
See you in the next video.

