04 Let's Learn Python by Examples: Date to Day Converter

Опубликовано: 11 Март 2026
на канале: TeachSmartLearnSmart
40
3

In this Python tutorial I am going show you how to count the number of days since the beginning of the current year.
The main focus is on the : Lists and for-loop.
This is the source code:
#By Abdul Rahman Dastagir
#Date to day converter

print("Date to day converter.")

month = int(input("Current month? "))
day = int(input("Current day? "))
daysOfMonths = (31 , 28 , 31 , 30 , 31, 30 , 31 , 31 , 30 , 31 , 30 , 31)
for pos in range (0 , month-1):
day = day + daysOfMonths[pos]
print(str(day) + " days has past since the beginning of the year.")