Diploma in Python Programming by www.alison.com
Diploma in Python Programming
by www.alison.com
DATE AND TIME FUNCTIONS
INPUT:
import datetime
date=input('Enter DOB dd/mm/yyyy format') or '20/08/1966'
ddate=datetime.datetime.strptime(date,'%d/%m/%Y').date()
print(datetime.datetime.strftime(ddate,'Your born on %A %B, %Y'))
diff=datetime.date.today()-ddate
print('Your Age Is',diff)
print('day',ddate.day,'Month',ddate.month,'year',ddate.year)
OUTPUT is as under
==============================================================
========= RESTART: C:/Users/S.A COMPUTER/AppData/Local/Programs/Python/Python311/temp ========
Enter DOB dd/mm/yyyy format
Your born on Saturday August, 1966
Your Age Is 21118 days, 0:00:00
day 20 Month 8 year 1966
=================================
Some Quiz Question practice:
There are a lot of different versions of Python that you could use, select three versions from the following list:
I think IronPython, JPython, Jython
In Python you can use triple quotes to enclose your text in the print statement to have your text display as you have typed into the editor. Why is this not a recommended method?
Ans may be Most of other language do not support it
Comments
Post a Comment