1
00:00:00,840 --> 00:00:06,230
In this video, you will learn how to do batch operations with Python.

2
00:00:06,240 --> 00:00:08,490
So what do I mean by that?

3
00:00:08,520 --> 00:00:11,990
Well, let's look at the current state of the program.

4
00:00:12,000 --> 00:00:17,590
So the program is asking the user three times for entering input.

5
00:00:17,610 --> 00:00:20,130
So we have three functions here.

6
00:00:21,110 --> 00:00:23,510
But as we mentioned, this is not sustainable.

7
00:00:23,870 --> 00:00:31,820
So what we want is to write the input function only once and somehow tell Python to execute it multiple

8
00:00:31,820 --> 00:00:32,570
times.

9
00:00:33,460 --> 00:00:34,750
So how do we do that?

10
00:00:34,870 --> 00:00:36,570
Well, let me show you that to you.

11
00:00:36,580 --> 00:00:38,290
I'll delete all these.

12
00:00:38,290 --> 00:00:40,150
We don't need them anymore.

13
00:00:42,810 --> 00:00:50,140
We only need the input function once here and then we make some space in here and we use a while.

14
00:00:50,160 --> 00:00:51,120
Look.

15
00:00:54,700 --> 00:01:01,960
So this starts with this wild keywords and then make a space and you put a condition.

16
00:01:03,190 --> 00:01:06,160
The conditions should be a true statement.

17
00:01:06,730 --> 00:01:12,100
Now, there are different ways to do this, but as a beginner, start with a simple statement such as

18
00:01:12,100 --> 00:01:14,590
to greater than one.

19
00:01:14,590 --> 00:01:16,950
So is to greater than one.

20
00:01:16,960 --> 00:01:17,650
Well.

21
00:01:17,680 --> 00:01:19,270
Yes, that's true.

22
00:01:19,270 --> 00:01:20,110
Always true.

23
00:01:20,140 --> 00:01:25,840
So when you put this column, I'll talk about that more in just a bit.

24
00:01:26,260 --> 00:01:31,690
And after the column, then you want to go here and you want to press space.

25
00:01:31,870 --> 00:01:33,250
Four times.

26
00:01:33,250 --> 00:01:35,980
One, two, three, four.

27
00:01:38,460 --> 00:01:41,850
And that is known as indentation.

28
00:01:42,450 --> 00:01:48,890
So that's part here for white spaces is is indentation and it is part of the syntax.

29
00:01:48,900 --> 00:01:51,180
So when you write this word keyword.

30
00:01:52,310 --> 00:02:00,710
Whatever comes down here, all the code is indented under that while keywords.

31
00:02:00,920 --> 00:02:02,810
So in this case.

32
00:02:04,510 --> 00:02:08,560
What we want to do is we want to ask the user for input.

33
00:02:08,830 --> 00:02:11,860
So I'll execute this now and you'll see what will happen.

34
00:02:12,100 --> 00:02:15,630
But first, let me rename this variable from 2 to 1 two.

35
00:02:15,640 --> 00:02:20,830
To do it makes more sense and right click and execute.

36
00:02:21,730 --> 00:02:23,380
So enter A to do.

37
00:02:24,860 --> 00:02:25,610
Clean.

38
00:02:27,310 --> 00:02:31,660
Again enter it to do through again meet.

39
00:02:33,880 --> 00:02:36,160
Free up Pluto.

40
00:02:37,750 --> 00:02:45,070
So we keep getting asked for to do over and over again, and this happens infinitely.

41
00:02:46,850 --> 00:02:48,080
Why does it happen?

42
00:02:48,080 --> 00:02:48,950
Infinitely?

43
00:02:48,980 --> 00:02:53,150
Well, because two is always greater than one.

44
00:02:54,580 --> 00:03:02,530
So the way the interpreter, the python interpreter is executing this script is this first it executes

45
00:03:02,530 --> 00:03:03,300
this line.

46
00:03:03,310 --> 00:03:11,530
It stores that enter a to do string to this variable and then it checks if two is greater than one.

47
00:03:11,740 --> 00:03:15,190
If it is, it executes this line.

48
00:03:17,960 --> 00:03:22,460
So we get that first prompt here and try to do.

49
00:03:24,410 --> 00:03:27,980
And then the interpreter looks if there are other lines down here.

50
00:03:28,280 --> 00:03:33,450
If not, it goes back to the wild loop to the first line.

51
00:03:33,470 --> 00:03:35,960
Again, it checks if two is greater than one.

52
00:03:35,960 --> 00:03:37,850
So it checks this condition.

53
00:03:37,850 --> 00:03:39,080
Two is greater than one.

54
00:03:39,080 --> 00:03:41,630
So it executes that line again.

55
00:03:42,110 --> 00:03:43,550
Enter A to do.

56
00:03:45,180 --> 00:03:48,660
To understand this better, you can stop the program.

57
00:03:51,140 --> 00:03:52,940
Use this button to stop it.

58
00:03:55,000 --> 00:03:58,810
And then you can print out the to do.

59
00:04:01,170 --> 00:04:02,550
And maybe print out.

60
00:04:04,850 --> 00:04:08,510
Next like that and execute.

61
00:04:08,510 --> 00:04:10,310
So enter it to do clean.

62
00:04:11,150 --> 00:04:19,670
So you see that Python executes this line first and then it prints out the to do that, the user enters

63
00:04:19,670 --> 00:04:26,870
it prints out next so that string and then it goes back again to the first line.

64
00:04:26,870 --> 00:04:29,150
It executes that line again.

65
00:04:29,690 --> 00:04:33,350
That's why this is called a loop.

66
00:04:33,560 --> 00:04:35,330
It's a while loop.

67
00:04:35,960 --> 00:04:40,940
We also have for loops, which is another type of loop, which we'll cover later on.

68
00:04:40,940 --> 00:04:44,930
We're going to need a for loop also as we develop the program.

69
00:04:45,970 --> 00:04:50,770
Before we close this video, I want to change something from this program.

70
00:04:53,010 --> 00:04:56,670
There is a simple way to write a condition.

71
00:04:56,670 --> 00:05:00,540
So instead of thinking, Oh, what is something that is true?

72
00:05:02,030 --> 00:05:06,440
Python has figured out a better way to just say true.

73
00:05:07,400 --> 00:05:10,160
So while true, execute this.

74
00:05:10,670 --> 00:05:11,330
So true.

75
00:05:11,330 --> 00:05:12,340
It's always true.

76
00:05:12,350 --> 00:05:14,840
Just like two is always greater than one.

77
00:05:14,840 --> 00:05:16,280
True is always true.

78
00:05:16,850 --> 00:05:18,860
So if I execute this program now.

79
00:05:20,220 --> 00:05:21,540
You can press that.

80
00:05:22,790 --> 00:05:24,380
To rerun the program.

81
00:05:26,290 --> 00:05:30,280
So now we are running the new script with through there.

82
00:05:30,700 --> 00:05:34,780
So enter clean and so you get asked for.

83
00:05:36,620 --> 00:05:39,410
To dos over and over again.

84
00:05:39,890 --> 00:05:41,360
So what is true?

85
00:05:41,390 --> 00:05:45,500
True is a Boolean is a data type.

86
00:05:46,370 --> 00:05:49,580
A Boolean is like strings and lists.

87
00:05:49,580 --> 00:05:52,010
So that was a string data type.

88
00:05:52,010 --> 00:05:53,660
This is a Boolean data type.

89
00:05:53,840 --> 00:05:58,460
And this here is a typical use of this data type.

90
00:05:58,460 --> 00:06:00,560
You can also have false here.

91
00:06:00,560 --> 00:06:01,730
False.

92
00:06:02,630 --> 00:06:06,050
But if we rerun the program.

93
00:06:07,040 --> 00:06:10,060
Nothing will happen because false is false.

94
00:06:10,070 --> 00:06:14,000
So none of these lines will be executed.

95
00:06:16,270 --> 00:06:22,180
Therefore, the end version is one to execute this.

96
00:06:23,590 --> 00:06:24,880
And that's about this video.

97
00:06:24,880 --> 00:06:30,280
So now the next step is to store these to dos in a list.

98
00:06:30,700 --> 00:06:31,870
How do we do that?

99
00:06:31,870 --> 00:06:33,430
I'll show you in the next video.

100
00:06:33,460 --> 00:06:33,730
See you.

