![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the first date of a given year using Python?
In this program, we have to print the first day of the year. We have to take a year as a user input.
Algorithm
Step 1: Import the datetime library. Step 2: Take year as input from the user. Step 3: Get the first day of the year by passing month, day and year as parameters to the datetime.datetime() function Step 4: Display the first day using strftime() function.
Example Code
import datetime year = int(input("Enter year: ")) firstday = datetime.datetime(year, 1,1) print("First Day of ", year, " = ", firstday.strftime("%A"))
Output
First Day of 2021 = Friday
Advertisements