Skip to content

Commit 979ef3b

Browse files
committed
Initial transcripts for all lectures / videos.
1 parent 97f6669 commit 979ef3b

File tree

382 files changed

+21629
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

382 files changed

+21629
-0
lines changed

transcripts/01-datetimes/1.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
00:00 Good day, this is Julian Sequeira
2+
00:02 and welcome to the course.
3+
00:03 We're going to open things up with playing with datetimes.
4+
00:07 Probably not the most interesting thing for most of us
5+
00:10 and if you're like me, you probably hate it
6+
00:13 because they can be very finicky.
7+
00:15 So, with datetimes I wanted to run us through
8+
00:19 some of the more basic concepts of it.
9+
00:21 Just go with it, there will be more advanced stuff coming up
10+
00:25 but for now we're going to stick with
11+
00:26 just the basics to get you through with datetimes
12+
00:29 specifically around datetimes.date
13+
00:33 and then datetimes.timedelta.
14+
00:36 So, we'll flick through into that,
15+
00:38 carry on, and let's get started.

transcripts/01-datetimes/2.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
00:00 Right a quick overview of what we're doing for the next
2+
00:03 couple of days.
3+
00:04 For the first day of your datetimes lessons you're going to
4+
00:08 watch the videos, okay?
5+
00:10 A couple of videos for you to watch to do with datetime,
6+
00:12 date, and timedelta.
7+
00:15 Alright after you've done, after you've completed watching
8+
00:17 the videos go ahead and just play around in the shell.
9+
00:21 So do some timestamp calculations as per the content
10+
00:25 in the videos.
11+
00:26 So we won't dwell on that too much.
12+
00:28 The second day I want you to head to our challenges,
13+
00:32 our challenges platform I should say and sign up with your
14+
00:36 GitHub account.
15+
00:37 It's free and then follow this link here and this will
16+
00:40 unlock this datetimes challenge, okay?
17+
00:46 This bite here is going to be based around parsing dates
18+
00:50 from logs.
19+
00:52 Okay so have a play with it, code in the browser
20+
00:55 and have fun.
21+
00:56 That's your day two.
22+
00:58 Then day three.
23+
01:00 That is all going to be up to you.
24+
01:02 Create something for yourself.
25+
01:04 I reckon you should give a Pomodoro timer a chance.
26+
01:08 Use datetime for it.
27+
01:10 I know you can just use a time module for these
28+
01:12 examples here but the idea is to include some timestamps.
29+
01:16 Do some calculations and see what you can wrap around date
30+
01:19 time okay so the Pomodoro timer is quite simple.
31+
01:24 You can do that or you can do a stop watch.
32+
01:26 Anything like that.
33+
01:28 So if you have any ideas yourself now is your time to
34+
01:30 test it out on day three.

transcripts/01-datetimes/3.txt

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
00:00 Given datetime is part of the Python standard lib,
2+
00:04 we don't actually have to do any setup here.
3+
00:07 You'll see in the coming videos
4+
00:09 that you will have to do setup steps,
5+
00:12 create virtual environments and whatnot,
6+
00:14 but given this is datetime, we don't really have to.
7+
00:17 And, I think it'd be best for us to just work
8+
00:20 in the Python shell here.
9+
00:21 This is IDLE, the default Python IDE
10+
00:25 that it ships with.
11+
00:27 So, let's have a play with that.
12+
00:29 Now, the first thing we're going to do
13+
00:31 is we're going to import datetime.
14+
00:34 But, we're actually going to do
15+
00:37 from datetime import datetime, okay?
16+
00:44 And, this is just going to make it a bit easier for us
17+
00:46 when we're typing in the rest of our code.
18+
00:48 And, just to get yourself prepared, let's just
19+
00:52 from datetime import date
20+
00:54 that's for a bit later in this video.
21+
00:58 Alright so what is datetime, alright.
22+
01:00 For those who are unaccustomed and unaware
23+
01:03 datetime is just the Python library module that allows
24+
01:07 you to deal with dates and times.
25+
01:11 Pretty self-explanatory, right?
26+
01:14 So, if you want to deal with just the dates
27+
01:18 so, you know, today's date, let's call it
28+
01:21 the 23rd of February 2018, not very specific.
29+
01:26 Or if you want to deal with the time
30+
01:29 that you've got to think about that
31+
01:30 from a programming perspective, there is a difference, okay.
32+
01:35 So, datetime allows us to deal with
33+
01:38 the entire time set, the entire timeframe.
34+
01:41 You're talking seconds, minutes, hours, days
35+
01:44 all the way through to years, okay?
36+
01:47 We can visualize that with datetime.today().
37+
01:52 If we hit enter, there we go, we can see today's date.
38+
01:57 The 24th of February 2018
39+
02:01 but we also get this timestamp.
40+
02:03 It's 10:17pm
41+
02:05 and these are the extra seconds here.
42+
02:08 So seconds, milliseconds and whatnot, okay?
43+
02:12 Now I'm going to show you this, what kind of an object is this?
44+
02:16 Well let's go, well first actually we have to assign that
45+
02:20 to something that way so, we'll just go with today.
46+
02:24 Here's datetime.today()
47+
02:28 alright and then we'll type it out, so type today.
48+
02:32 So it's a datetime object, okay?
49+
02:35 And that's important because you can't mix these objects.
50+
02:39 I'll point that out in just a minute.
51+
02:42 So with this timestamp, there is more you can do with that.
52+
02:46 And I'll show you that in the next video with timedelta.
53+
02:51 Alright, but for now just understand that this is what your
54+
02:53 standard datetime format will look like.
55+
02:56 This is the sort of data you're going to get back.
56+
02:59 And this is really useful for times when you want to
57+
03:03 deal with say, subscriptions or anything like that
58+
03:06 where it has to do with exact timestamps, or logging
59+
03:10 or anything where you need to know
60+
03:13 the time that something happened.
61+
03:15 Going by the date of say, the 24th of February
62+
03:19 is not accurate enough, okay, there is 24 hours
63+
03:22 within that day so, a lot of things could have happened.
64+
03:25 Alright, so we'll move on to the date part here.
65+
03:30 So we'll just go today date, we'll create that variable.
66+
03:34 Here's date.today(), so you can see straightaway
67+
03:38 we're not using datetime, we're using the date section
68+
03:43 okay, we're using the date option here.
69+
03:45 So date.today()
70+
03:48 and if we type that out
71+
03:53 Today date, we can see
72+
03:56 the different type of object here.
73+
03:58 First one was a datetime and now it's a date object, okay?
74+
04:04 And we can see what that looks like with today date.
75+
04:09 And we have just the date string, okay?
76+
04:12 So we don't have the extra time on the end.
77+
04:15 And this is, again, very useful.
78+
04:18 So you can see the distinction between the two of them.
79+
04:21 Alright let's get ourselves a little bit of white space.
80+
04:25 Now one really cool thing that I love about date
81+
04:30 is that we can drill into it a little more, so we can go
82+
04:36 today.month is 2.
83+
04:41 So you can see we can actually tear it apart a bit.
84+
04:44 So today.day
85+
04:47 is 24 and then
86+
04:51 today.year, and we get 2018.
87+
04:57 So now you can sort of visualize how date can help you
88+
04:59 in your projects, right, if you're not already using it.
89+
05:03 It's actually really cool.
90+
05:04 So one really, really cool thing that
91+
05:07 has come in handy over time,
92+
05:10 is the fact that you can do
93+
05:11 a bit of math with your dates, alright.
94+
05:15 So we'll go, let's just go something easy.
95+
05:18 So Christmas, what's the date for Christmas?
96+
05:21 It's the, we'll go year first, so 2018.
97+
05:25 It's the month next, so 12.
98+
05:29 And then it's the day, so 25th, alright.
99+
05:35 Now one thing, if you had a look, this is ...
100+
05:40 us specifying a date, this is us
101+
05:42 assigning a date to a variable.
102+
05:45 So now the Christmas variable is always going to
103+
05:50 have this date assigned to it.
104+
05:54 You can see that there, okay.
105+
05:57 Now, this is really cool, so
106+
06:00 We can actually go Christmas, cause we know that's
107+
06:04 the end of this year, minus, today date.
108+
06:10 Kay, and that's 304 days, it automatically called
109+
06:15 on timedelta, so that's giving away something for the next
110+
06:18 video but, carry on, 304 days.
111+
06:22 Alright, and we can see that visualized a different way.
112+
06:25 We can, and this is again giving more away
113+
06:27 we can go Christmas
114+
06:31 minus today
115+
06:35 in days, so .days.
116+
06:39 304 days, alright and this is really cool for something
117+
06:43 such as this, I'm just going to copy and paste here
118+
06:46 rather than type it all out for you, alright.
119+
06:50 So if Christmas is not today date
120+
06:55 well what can we do?
121+
06:56 We can print a certain message.
122+
06:58 Again, you can see this is useful for certain other projects
123+
07:03 so print, sorry there are still this many days
124+
07:09 (christmas minus today).days, until Christmas.
125+
07:13 Okay, and then else ...
126+
07:16 We'll copy and paste this as well.
127+
07:20 We're going to print some sort of message, alright.
128+
07:25 "Yay, it's Christmas."
129+
07:27 So, by hitting enter, sorry there are still 304
130+
07:32 the same value here, until Christmas.
131+
07:35 I've obviously left out the word 'days'
132+
07:37 so that's my mistake, but
133+
07:38 sorry there are still 304 days until Christmas.
134+
07:42 If I happen to wait another, you know, ha ha ha ha
135+
07:46 that many days, 304 days
136+
07:48 we would then get this message here.
137+
07:51 So this is date and this is datetime.
138+
07:54 Very, very tedious at times, I want to say
139+
07:59 but so useful, so this is a great place to start
140+
08:02 manipulating your code, manipulate your dates
141+
08:06 and have some fun with it.
142+
08:08 And in the next video we're going to look at datetime.

transcripts/01-datetimes/4.txt

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
00:00 Okay, just like the previous day,
2+
00:02 we're going to look at something
3+
00:04 but we're going to use the Python shell for this one.
4+
00:06 And specifically today we're looking at timedelta.
5+
00:11 So what is timedelta?
6+
00:12 Well, timedelta is pretty much a gap in time measured out.
7+
00:18 So, for example, if you want to calculate something such as
8+
00:22 how many hours from now until a certain point in time,
9+
00:25 you can use timedelta for that to specify
10+
00:28 what it's going to be.
11+
00:30 A real world example.
12+
00:31 How many hours until I go to bed?
13+
00:33 Well, let's say it's going to be four hours.
14+
00:36 So my timedelta, you can specify for this calculation,
15+
00:40 is four hours.
16+
00:42 And four hours from now could be two in the morning, okay?
17+
00:46 So it's different...
18+
00:49 That's how you calculate things like that,
19+
00:51 you use timedelta.
20+
00:53 All right, so how do we do that?
21+
00:55 Well, we go from datetime import datetime just like usual,
22+
01:01 from datetime import timedelta.
23+
01:06 All right, so let's represent our timedelta as a variable t
24+
01:12 timedelta and let's work on days and hours.
25+
01:17 So let's say we have four days and 10 hours
26+
01:20 until my next day off work, it's pretty depressing.
27+
01:24 And how do we deal with this? How do we work with this?
28+
01:28 Well, let's first of all confirm we have a timedelta
29+
01:31 object there, excellent.
30+
01:33 And what next? What can we do with this?
31+
01:36 Well, we can go how many days in there.
32+
01:38 So t.days.
33+
01:41 That gives us four days, okay?
34+
01:44 One important thing to note here, watch this next one.
35+
01:48 T.seconds.
36+
01:50 36,000.
37+
01:51 So 36,000 seconds is not four days 10 hours.
38+
01:58 36,000 seconds is just the 10 hours.
39+
02:02 And why is that?
40+
02:03 Well, this timedelta is just like...
41+
02:07 Imagine the stopwatch on your watch,
42+
02:10 it's only able to go up to a certain amount of time, right?
43+
02:12 Maybe 23 hours and 59 minutes.
44+
02:15 So with timedelta, the seconds, it's only able to go up
45+
02:19 to a maximum of one day, okay?
46+
02:23 So we have four full days here,
47+
02:26 so it's not going to show us the seconds in four full days.
48+
02:29 It's only going to show us the seconds in the hours.
49+
02:33 So you have to take that into account and your calculation.
50+
02:36 Okay?
51+
02:38 We could calculate the hours but not like this.
52+
02:43 Okay?
53+
02:44 It doesn't allow us to do this because it has seconds,
54+
02:46 it's not going to bother with hours, all right?
55+
02:50 So in order to get around this,
56+
02:52 well, you have to do a bit of maths,
57+
02:53 unfortunately for people like me.
58+
02:56 So t.seconds divided by 60
59+
03:01 and divided by 60 again.
60+
03:03 Well, because we have 60 seconds in a minute
61+
03:06 and then 60 minutes in an hour.
62+
03:08 And that gives us that 10 hours.
63+
03:10 Alternatively, you could write that as t.seconds
64+
03:14 / 3,600.
65+
03:16 Same thing, okay?
66+
03:19 That's a really important gotcha
67+
03:21 because it definitely got me.
68+
03:25 back at the start.
69+
03:26 So here is an example of a sort of scenario
70+
03:30 you could use it in,
71+
03:31 but just keep in mind, timedelta is that gap,
72+
03:35 it's that sort of way of representing the time
73+
03:38 between two points in time, okay?
74+
03:42 All right, so we have an ETA.
75+
03:44 Well, let's just say it's the ETA until
76+
03:49 I wake up.
77+
03:50 So hours equals six.
78+
03:53 We're not even going to talk days here, okay?
79+
03:57 We can go today.
80+
03:59 We'll give ourselves a datetime today, variable, okay?
81+
04:04 We're not dealing with just date,
82+
04:06 we're dealing with day time because we want the time,
83+
04:08 we want the minutes, the seconds, the hours, right?
84+
04:11 So there we go, we've got two variables, ETA and today.
85+
04:16 All right? So today, let's just show you what that is.
86+
04:19 It's currently 10:39 p.m., okay?
87+
04:25 Let's get rid of that.
88+
04:28 All right.
89+
04:29 We can go what is ETA?
90+
04:32 Is our timedelta, all right?
91+
04:35 Now, what next?
92+
04:38 We want to add these two together, okay?
93+
04:42 So we can go today + ETA,
94+
04:46 this is the beauty, the absolute beauty of timedelta,
95+
04:51 we can just add it straight to a datetime object
96+
04:55 which is so cool and so handy and it makes it so easy.
97+
05:00 So today plus ETA.
98+
05:03 And look at that time.
99+
05:05 It actually changed the date to the 25th
100+
05:09 because we'd cross over midnight
101+
05:11 and it says six hours from now is 4:39 a.m., okay?
102+
05:17 And this is really, really cool
103+
05:19 because you don't have to worry about any conversions,
104+
05:21 you don't have to change anything.
105+
05:24 It's so easy.
106+
05:25 And even better than that,
107+
05:27 we can format it, so today + ETA as a string.
108+
05:34 Look at that, it's glorious.
109+
05:37 We have an actual nicely formatted date string
110+
05:42 and time stamp.
111+
05:45 How awesome is that?
112+
05:47 And that's timedelta,
113+
05:49 that's really the bread and butter of timedelta.
114+
05:51 You're dealing with just setting yourself a static time,
115+
05:55 a static amount of time
116+
05:56 and then you can add it, subtract it,
117+
05:58 do whatever you want with it.
118+
05:59 And this is really useful in a lot of programs,
119+
06:03 so keep this one in your belt

transcripts/01-datetimes/5.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
00:00 Okay, and that was the basic overview
2+
00:02 of datetimes.
3+
00:04 How cool was that?
4+
00:05 Not too bad, not too hard.
5+
00:06 Nice way to start your #100DaysOfCode on Python, right?
6+
00:10 Alright, so let's do a quick recap of what we covered.
7+
00:13 There wasn't a lot so this will be pretty quick.
8+
00:16 So we began by importing datetime and date.
9+
00:19 And we then started to look at the differences
10+
00:22 between datetime and date.
11+
00:24 So a datetime object, well when we ran datetime.today(),
12+
00:28 it included the date and the time,
13+
00:31 so we had a timestamp in that object.
14+
00:34 Whereas when we ran that with just date,
15+
00:37 we only get the actual date, the calendar date.
16+
00:40 So we the 19th of February 2018, alright.
17+
00:44 And we found that you can't actually easily combine the two,
18+
00:48 do maths between the two.
19+
00:50 Okay, not without a lot of conversion.
20+
00:55 First we gave ourselves a Christmas variable,
21+
01:00 and we gave it its' actual date,
22+
01:02 which is something you can do with date.
23+
01:04 You can assign an actual date to an object.
24+
01:08 Once we did that, we were then actually able to calculate
25+
01:12 the amount of days between Christmas and the current date.
26+
01:16 So that was just a bit of a little scenario
27+
01:18 for you to use datetime and date.
28+
01:21 Okay, next we played with timedelta.
29+
01:27 Now we began by importing timedelta
30+
01:29 and then we gave ourselves a timedelta object.
31+
01:33 So we set the timedelta length as 4 days and 10 hours.
32+
01:39 Then we discussed the fact that you can view your timedelta
33+
01:44 in those days and you can view it in seconds,
34+
01:49 but you can't view it in hours, okay.
35+
01:52 And that's because it only works in days and seconds.
36+
01:55 And the seconds only go up to a max
37+
01:57 of the 24 hours of a day.
38+
02:00 They expect you to do the calculations yourself.
39+
02:04 And that's what we see here.
40+
02:07 t.seconds / 60 / 60,
41+
02:10 and then we get our ten hours, okay, matches up there.
42+
02:15 As a little scenario to try, we wanted to look at the ETA.
43+
02:20 We wanted to add the estimated time of arrival
44+
02:23 onto the current time.
45+
02:26 So the current time plus six is that there,
46+
02:31 that's the object there.
47+
02:33 That's the response there I should say, the calculation.
48+
02:37 And we were able to add and subtract
49+
02:39 timedelta from datetimes which is really, really cool
50+
02:45 and makes it really easy.
51+
02:48 And using string on that, converting it to a string,
52+
02:51 we got a really nicely formatted timestamp here.
53+
02:55 Very useful for log files right.
54+
02:58 Alright, your turn.
55+
03:02 This is where it gets a lot of fun.
56+
03:04 What I'd like you to do for day three
57+
03:06 is come up with something cool for you to make
58+
03:09 with datetime or timedelta.
59+
03:12 Think about perhaps making it a stopwatch,
60+
03:16 maybe a timer application.
61+
03:19 I actually think a really fun one to make
62+
03:20 would be a Pomodoro timer.
63+
03:22 So if you're not familiar with Pomodoro,
64+
03:23 just go and google it.
65+
03:25 But that would be a really cool way
66+
03:27 of setting specific timestamps that a user could choose
67+
03:32 using datetime and what have you.
68+
03:34 So that would be really, really fun.
69+
03:36 Now I know what you're thinking,
70+
03:37 datetime is a really deep and in-depth topic,
71+
03:41 but unfortunately we just don't have the time
72+
03:45 to run it in this course.
73+
03:48 So I hope you really enjoyed it.
74+
03:50 Move onto the next video,
75+
03:51 we are keeping it nice and simple for the first day.
76+
03:54 Expect things to take it up a notch going forward.
77+
03:57 So enjoy, get cracking, don't waste any time.

0 commit comments

Comments
 (0)