Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,176,488 members, 7,898,027 topics. Date: Tuesday, 23 July 2024 at 06:11 AM

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

Nairaland Forum / Science/Technology / Programming / Check Out My Python Code For Giving You The Date/time You Are Currently. (1153 Views)

Please Review My Price comparison engine / My Python Guessing Game... Pythonistas Please Come In / Please Help With My Python Shopping Cart Script (2) (3) (4)

(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)

The Little Match Girl / Beginning Java Programming / I Need A Business Software Developed. Anyone? Can You Recommend Anyone?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.