1
00:00:00,600 --> 00:00:03,380
Hello and welcome to this video.

2
00:00:03,630 --> 00:00:15,360
What are built in modules built in modules the modules that Python has already created for you before

3
00:00:15,360 --> 00:00:25,570
you can use the built in modules you need to use the import statement to access them.

4
00:00:25,650 --> 00:00:32,490
I'm going to show you a couple of example modules that are built in that we can use.

5
00:00:32,580 --> 00:00:36,450
The first one is a module called random.

6
00:00:36,450 --> 00:00:42,810
This module is basically used to generate random numbers.

7
00:00:42,810 --> 00:00:45,540
We can use the module we have to import it.

8
00:00:45,540 --> 00:00:52,860
So you do that by using the input statement which is import and then type in the name of the module

9
00:00:53,130 --> 00:01:00,000
the module is called random and it is used to generate random numbers say for example have a variable

10
00:01:00,000 --> 00:01:07,010
called X and set it to equals two random random being the module.

11
00:01:07,020 --> 00:01:14,250
So what this code on line 3 is basically X is a variable I created an offset to close to the module

12
00:01:14,250 --> 00:01:21,730
random and inside that module random I am using a function called random.

13
00:01:21,780 --> 00:01:22,130
All right.

14
00:01:22,140 --> 00:01:28,260
So what I can do I can print this out on the screen by using a print statement.

15
00:01:28,290 --> 00:01:37,440
I can just say print inside the print function I can pass in X which is the value of this which is this

16
00:01:37,500 --> 00:01:42,210
x variable which would give me a random number.

17
00:01:42,300 --> 00:01:50,480
So let me click on the play button I can see here is giving me a random number if I click on play again

18
00:01:50,730 --> 00:01:54,480
the number will change because it's giving me another one.

19
00:01:54,480 --> 00:01:58,110
If I click play again it changes the number.

20
00:01:58,230 --> 00:02:10,940
It generates the number it has generated is basically a float so a float is a number that has decimal.

21
00:02:11,090 --> 00:02:20,660
Now inside this module called random it has all the functions as well that one can use.

22
00:02:20,660 --> 00:02:23,860
One of them is called round INT.

23
00:02:23,900 --> 00:02:25,250
What that does.

24
00:02:25,440 --> 00:02:31,930
It can round numbers into an integer which is a whole number.

25
00:02:31,970 --> 00:02:41,120
So if I want to say generate a number that will be a whole number I can for example create another variable.

26
00:02:41,120 --> 00:02:49,160
If I want to say I just created variable Y and I'll just set it to equals to random which is a module

27
00:02:49,550 --> 00:02:57,890
I do a dot and then from that module random I'm going to use a function called a round int which is

28
00:02:57,920 --> 00:03:03,470
what will convert whatever random numbers generated into an integer.

29
00:03:03,470 --> 00:03:13,430
So I'm going to pass in to values 0 and 50 so what I will do is to generate random integer number from

30
00:03:13,580 --> 00:03:15,550
0 to 50.

31
00:03:15,590 --> 00:03:24,590
So for that to happen I need to add a print function I'm passing the variable y into that print function.

32
00:03:24,590 --> 00:03:27,220
Now let me play this and then you can see.

33
00:03:28,440 --> 00:03:31,210
So this is the first one.

34
00:03:31,220 --> 00:03:37,600
That's the first print on line number four where it generates a random number which is a float and their

35
00:03:37,610 --> 00:03:43,810
line number six here is the way I use the front end function.

36
00:03:43,820 --> 00:03:44,750
Line number seven.

37
00:03:44,780 --> 00:03:45,910
I'm telling you to print.

38
00:03:45,910 --> 00:03:47,960
Why so does it there.

39
00:03:47,990 --> 00:03:53,300
So what does it generate a random number then convert it into an integer.

40
00:03:53,540 --> 00:04:00,290
So any random number between 0 and 50 see if I click play again it will give me a different number this

41
00:04:00,290 --> 00:04:08,210
time I can say is given me forty seven so any number between 0 and 50 so when you reusing the rand end

42
00:04:08,570 --> 00:04:16,220
you can always specify the range you want it to generate from there's another module I want to quickly

43
00:04:16,280 --> 00:04:22,700
introduce you to is called the platform module is used to basically detect what platform your system

44
00:04:22,700 --> 00:04:23,380
is running on.

45
00:04:23,380 --> 00:04:30,050
So to use it again we need to import it so I type in import space followed by the name of the module

46
00:04:30,100 --> 00:04:31,970
is called platform.

47
00:04:32,030 --> 00:04:35,810
So now that I've imported it I can use it in my file.

48
00:04:35,810 --> 00:04:38,080
So I'm just going to create a variable called J.

49
00:04:38,090 --> 00:04:44,000
And I'm going to set it to a course to platform dot.

50
00:04:44,000 --> 00:04:48,360
So from the platform module there's a function called system.

51
00:04:48,410 --> 00:04:56,600
So I'm using that function code system and I'm just going to attach a print statement as I say print

52
00:04:57,130 --> 00:05:00,350
on a passing the variable j.

53
00:05:00,350 --> 00:05:07,010
Now if I print that issue tell me what platform I am running on so I click on play.

54
00:05:07,530 --> 00:05:10,210
I can see here it says windows.

55
00:05:10,210 --> 00:05:10,730
All right.

56
00:05:10,730 --> 00:05:14,450
So if you're on a Mac you should say Mac and so on.

57
00:05:15,110 --> 00:05:24,470
So that's how you can use beauty in modules you first of all have to import them and then you can access

58
00:05:25,550 --> 00:05:30,160
either different parts from that module that you want to use.

59
00:05:30,170 --> 00:05:31,010
So that's it.

60
00:05:31,010 --> 00:05:31,990
Thanks for watching.

61
00:05:32,120 --> 00:05:33,090
And bye for now.
