₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,080 members, 8,420,203 topics. Date: Thursday, 04 June 2026 at 01:26 PM

Toggle theme

Check Out My Python Code For Giving You The Date/time You Are Currently. - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingCheck Out My Python Code For Giving You The Date/time You Are Currently. (1264 Views)

1 Reply (Go Down)

Check Out My Python Code For Giving You The Date/time You Are Currently. by Nobody: 11:32pm On Nov 13, 2015
I am very new to programming; check out one of my first programs, tell me what you think, and helpe smoothen the rough edges. cool:

""" A program for giving you information about any date and time parameter you are currently in, coded by Dee"""

from datetime import datetime
now = datetime.now()
months = ["January","Febuary","March","April","May","June","July","August","September","October","November","December"]


while True:
Time = raw_input("what aspect of the time do you want to know? "wink
Time = Time.lower()

if Time == "year":
print now.year
elif Time == "month":
print months[int(now.month)-1]
elif Time == "day" and now.day !=1 and now.day !=2:
print str(now.day) + "th"
elif now.day == 1:
print "1st"
elif now.day == 2:
print "2nd"
elif Time == "hour":
print now.hour
elif Time == "minute":
print now.minute
elif Time == "second":
print now.second
else:
print "I am sorry, try something else"
Re: Check Out My Python Code For Giving You The Date/time You Are Currently. by Nobody: 11:33pm On Nov 13, 2015
Nairaland won't permit me to indent the code properly , the way it should be
Re: Check Out My Python Code For Giving You The Date/time You Are Currently. by JigsawKillah(m): 1:42pm On Nov 14, 2015
Dapo777:

""" A program for giving you information about any date and time parameter you are currently in, coded by Dee"""

from datetime import datetime
now = datetime.now()
months = ["January","Febuary","March","April","May","June","July","August","September","October","November","December"]


while True:
Time = raw_input("what aspect of the time do you want to know? "wink
Time = Time.lower()

if Time == "year":
print now.year
elif Time == "month":
print months[int(now.month)-1]
elif Time == "day" and now.day !=1 and now.day !=2:
print str(now.day) + "th"
elif now.day == 1:
print "1st"
elif now.day == 2:
print "2nd"
elif Time == "hour":
print now.hour
elif Time == "minute":
print now.minute
elif Time == "second":
print now.second
else:
print "I am sorry, try something else"
if you type your codes between [code][/code] they'll indent. I'm a learner like you too.
Re: Check Out My Python Code For Giving You The Date/time You Are Currently. by Nobody: 2:30am On Nov 15, 2015
JigsawKillah:
if you type your codes between [code][/code] they'll indent. I'm a learner like you too.
Thanks pal
1 Reply

Please Review My Price comparison engineMy Python Guessing Game... Pythonistas Please Come InPlease Help With My Python Shopping Cart Script234

Checkout The New Android App Designed By A NairalanderProgramming ContestWant To Be In A Community Of Java Programmers