Practice #25: Count the number of Friday 13th in the given year _ Python Coding for Beginners

preview_player
Показать описание
#Python #Programming #for #Beginners

Check out my video for the guide to format and convert date/time object to string object:

Below are the character codes to format the date and time:
%d: Returns the day of the month, from 1 to 31.
%m: Returns the month of the year, from 1 to 12.
%Y: Returns the year in four-digit format (Year with century). like, 2021.
%y: Returns year in two-digit format (year without century). like, 19, 20, 21
%A: Returns the full name of the weekday. Like, Monday, Tuesday
%a: Returns the short name of the weekday (First three character.). Like, Mon, Tue
%B: Returns the full name of the month. Like, June, March
%b: Returns the short name of the month (First three character.). Like, Mar, Jun
%H: Returns the hour. from 01 to 23.
%I: Returns the hour in 12-hours format. from 01 to 12.
%M: Returns the minute, from 00 to 59.
%S: Returns the second, from 00 to 59.
%f: Return the microseconds from 000000 to 999999
%p: Return time in AM/PM format
%c: Returns a locale’s appropriate date and time representation
%x: Returns a locale’s appropriate date representation
%X: Returns a locale’s appropriate time representation
%z: Return the UTC offset in the form ±HHMM[SS[.ffffff]] (empty string if the object is naive).
%Z: Return the Time zone name (empty string if the object is naive).
%j: Returns the day of the year from 01 to 366
%w: Returns weekday as a decimal number, where 0 is Sunday and 6 is Saturday.
%U: Returns the week number of the year (Sunday as the first day of the week) from 00 to 53
%W: Returns the week number of the year (Monday as the first day of the week) from 00 to

some useful date attributes/methods you might need to work with datetime objects:

-------------------------
Python Tutorial for Beginners,
Python Coding for Beginners,
Python Programming for Beginners,
Learn Python by Building Projects,
Python Exercises and Practical Examples with solutions,
Practice Python Online with solution,
How to write a Python program,
Python Programming Data Structure and Algorithm,
Python Problem Solving,
Python Game Tutorial,
Python Game Programming,
Python Game Development,
Python Tips and Tricks,

tags:
How do I display weekday in Python?
How do I get the current week Monday date in Python?
How do you get weekend and weekday in Python?
How do you print days in Python?
how to get weekday from a given date in python?
How to get day name from datetime - python
Python Get date from weekday of current week
python - How to get which day of week is a specific date
How do you use the date method in Python?
What are date formats in Python?
How do you represent a date in Python?
Is there a date data type in Python?
How to Format date using strftime() in Python
Using Python datetime to Work With Dates and Times
get date from datetime python
Рекомендации по теме
Комментарии
Автор

This is a very basic practice with Python datetime module and date() class function. To create a date, we can use the date() class (constructor) of the datetime module. The date() class requires three parameters to create a date: year, month, day.

makeeverydayezday
Автор

I like the way you write the one-line sum function code. It's also my preferred of doing the counting. Cheers!

philworley
Автор

In 'strftime, ' the 'f' is for 'format, ' and in 'strptime, ' the 'p' is for 'parse.' Knowing this helps you remember them better. Great video by the way.

tsudashiro
Автор

Love the explanation. Simple and easy to follow. I was confused about conversion between datetime and string objects until i saw ur video. Just wanted to say thanks

tombray
Автор

Hi, I am doing the Python exercise: "how many times so far your birthday has fallen on a Saturday."
And thanks to your approach in this video, I solved mine easily. Thanks a ton

dennisirwin
Автор

To whom might be interested:
how to combine date and time together:

import datetime, date, time

# (hours, minutes)
_time = time(7, 0)

# (year, month, day)
_date = date(2018, 6, 11)

# Create a datetime object
_datetime = datetime.combine(_date, _time)

timothyleary
Автор

Hi, I've got a question: I see that I can create a datetime object by using datetime(year, month, date) or date(year, month, date). So what are the differences between these two functions? Thanks in advance!

joomla
visit shbcf.ru