Time management function

Python Programming More of Python
6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.09
List Price:  €93
You save:  €27.90
£56.02
List Price:  £80.04
You save:  £24.01
CA$96.21
List Price:  CA$137.46
You save:  CA$41.24
A$106.50
List Price:  A$152.16
You save:  A$45.65
S$94.88
List Price:  S$135.55
You save:  S$40.67
HK$547.08
List Price:  HK$781.57
You save:  HK$234.49
CHF 63.59
List Price:  CHF 90.85
You save:  CHF 27.25
NOK kr764.52
List Price:  NOK kr1,092.22
You save:  NOK kr327.70
DKK kr485.54
List Price:  DKK kr693.66
You save:  DKK kr208.12
NZ$116.87
List Price:  NZ$166.97
You save:  NZ$50.09
د.إ257.07
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,696.46
List Price:  ৳10,995.41
You save:  ৳3,298.95
₹5,845.02
List Price:  ₹8,350.38
You save:  ₹2,505.36
RM331.92
List Price:  RM474.20
You save:  RM142.27
₦98,297.45
List Price:  ₦140,430.95
You save:  ₦42,133.50
₨19,467.44
List Price:  ₨27,811.82
You save:  ₨8,344.38
฿2,586.11
List Price:  ฿3,694.61
You save:  ฿1,108.49
₺2,257.70
List Price:  ₺3,225.42
You save:  ₺967.72
B$355.19
List Price:  B$507.43
You save:  B$152.24
R1,300.44
List Price:  R1,857.85
You save:  R557.41
Лв127.53
List Price:  Лв182.19
You save:  Лв54.66
₩95,343.18
List Price:  ₩136,210.38
You save:  ₩40,867.20
₪259.39
List Price:  ₪370.57
You save:  ₪111.18
₱4,014.38
List Price:  ₱5,735.07
You save:  ₱1,720.69
¥10,876.02
List Price:  ¥15,537.84
You save:  ¥4,661.82
MX$1,183.66
List Price:  MX$1,691.01
You save:  MX$507.35
QR254.83
List Price:  QR364.06
You save:  QR109.23
P952.42
List Price:  P1,360.66
You save:  P408.23
KSh9,168.69
List Price:  KSh13,098.69
You save:  KSh3,930
E£3,329.50
List Price:  E£4,756.64
You save:  E£1,427.13
ብር3,992.74
List Price:  ብር5,704.16
You save:  ብር1,711.42
Kz58,583.02
List Price:  Kz83,693.62
You save:  Kz25,110.60
CLP$65,554.03
List Price:  CLP$93,652.63
You save:  CLP$28,098.60
CN¥505.70
List Price:  CN¥722.46
You save:  CN¥216.76
RD$4,071.34
List Price:  RD$5,816.45
You save:  RD$1,745.10
DA9,415.49
List Price:  DA13,451.28
You save:  DA4,035.78
FJ$159.21
List Price:  FJ$227.46
You save:  FJ$68.24
Q544.84
List Price:  Q778.38
You save:  Q233.53
GY$14,671.19
List Price:  GY$20,959.74
You save:  GY$6,288.55
ISK kr9,784.60
List Price:  ISK kr13,978.60
You save:  ISK kr4,194
DH703.12
List Price:  DH1,004.51
You save:  DH301.38
L1,240.96
List Price:  L1,772.88
You save:  L531.91
ден4,012.27
List Price:  ден5,732.06
You save:  ден1,719.79
MOP$564.93
List Price:  MOP$807.08
You save:  MOP$242.14
N$1,294.05
List Price:  N$1,848.73
You save:  N$554.67
C$2,581.34
List Price:  C$3,687.79
You save:  C$1,106.44
रु9,369.68
List Price:  रु13,385.83
You save:  रु4,016.15
S/261.57
List Price:  S/373.68
You save:  S/112.11
K271.48
List Price:  K387.85
You save:  K116.36
SAR262.48
List Price:  SAR374.99
You save:  SAR112.51
ZK1,900.47
List Price:  ZK2,715.07
You save:  ZK814.60
L323.94
List Price:  L462.80
You save:  L138.85
Kč1,630.83
List Price:  Kč2,329.86
You save:  Kč699.02
Ft25,346.53
List Price:  Ft36,210.88
You save:  Ft10,864.35
SEK kr763.26
List Price:  SEK kr1,090.42
You save:  SEK kr327.16
ARS$61,644.55
List Price:  ARS$88,067.42
You save:  ARS$26,422.86
Bs483.68
List Price:  Bs691.01
You save:  Bs207.32
COP$273,058.61
List Price:  COP$390,100.45
You save:  COP$117,041.84
₡35,861.91
List Price:  ₡51,233.50
You save:  ₡15,371.58
L1,732.92
List Price:  L2,475.71
You save:  L742.78
₲523,307.77
List Price:  ₲747,614.58
You save:  ₲224,306.80
$U2,685.15
List Price:  $U3,836.09
You save:  $U1,150.94
zł280.89
List Price:  zł401.29
You save:  zł120.40
Already have an account? Log In

Transcript

So in this lesson, we'll show you how to work with date and time. So to use time function, which includes the date, we have to first import a library that contains this function, which is called the timeline. So, here I am, right input time. So run it now here and write, print within this first bracket, time dot time now see what it prints prints built in function time, because I haven't provided a first record over here. Now what it prints strange a series of numbers for what this number is, we really cannot understand. So here the program actually trains the series of numbers, which are the result of the kind of days minutes hours from 1972.

Now in fact, if we rerun this particular program so I'm just copying it and pasting it over here and I'll rerun it see we got a different number. Now to get it in local time what we can do is is So, print within this first bracket right time dot local time within this first record I right time dot time again first record now run it. So when you run it, you got that C tm year 2019 to a month 11 that is November tm, MD month D is equal to 11. So today is 11th November 2019. And tm minute is equal to one tm second is equal to 13 and tm be equal to zero and t where t is equal to 315. So these are the details of the local time now to make it much more easier to read.

So we can write print time dot h See time then again within this first record just copy the whole thing okay. Now printed So, what it gives it gives Monday November 11 okay year is 2019 and the time is two 318 that is to our three minutes 18 seconds So, this is much more easier to read now we can also customize the display method to our liking. So, for that we can write print within this first bracket time dot str f time then again within this first bracket open a quotes and write percent d dash then percent in again a dash then percent y now, give us space after one then right for sent h Kowloon port sent in colon and or sent is so after this Eva comma and write time dot local time and give the pair of first record so now run it we print it today's date and today's time in this way.

So person D refers to the day percent and refers to the month and year y is should be in capital. So percent y refers to the year here and here percent h refers to the our percent m refers to the minute and percentage refer to the second so in this way, you can customize your view the way you want to display your date. Now, you can also view the month calendar. So you can write input calendar. So now just run it. And here, you will right click Now right calendar dot month and then within this first bracket provide the year so here I write 2019 comma and then provide the month so first I have to mention the year then I have to mention the month so I have written seven that is for July I'ma run again I've got an error because here I've done a spelling mistake this should be a so be careful with your Spelling's, be careful with your cases because Python is very case sensitive so you have run it and see you have got the calendar for the month of July 2019.

If you change the value from here now you want the calendar for August so just run it and you will get the result of your August calendar. Now Now I'm go a little bit off topic. Now I have to tell you something we can do with all the functions so in Python and which could also be very useful, especially for beginners. So, when we work in Python, we could not find function that we don't know how to use at that point. So suppose you know the name of the function, but you don't know how to use that particular function for that we can write a print function and ask for help. So how you can use it.

So just write print, then within bracket right help. Then again, here, the function name is calendar dot month. So here I'll write the function name, calendar dot month. Now run it. See, the help window has printed something for you. So what it printed format month, year, then month, then method of calendar takes calendar instance return a month calendar string, so what it returns it will also tell you now as a beginner Now, it is very not that easy for you to understand all the attributes of this function.

Now as you go on practicing and keep writing your program keep writing your codes then you will get to know or you will be able to understand what these attributes are for. So, the important thing is to write the code and only by writing them and practicing it by yourself you will be able to fully understand this programming language will not get back to this lesson. So, today we have learned this time management function that is how you can use time and date in Python. So, keep practicing See you in the next video. Thank you

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.