Hi, I'm new to these forums. I've been working with java in school, but I can't stand the language. So I've been working with python and find it's very easy to understand, and I actually enjoy working with it.
So just for fun I've been working on a pretty basic program, that converts military time in to standard time and vice versa.
If you guys could answer these questions, it would be awesome, and I would be very grateful.
1) Is it possible to print a time value with a 0 in front of it? (Ex. 0300 hours)
2) Is it possible to print a time value with a colon in it? (Ex. 12:30)
3) Is it possible to be able to enter time values with the colon in it? (Enter a time: 12:30)
Here is the code.
####There might be some errors in the conversions still. I'm still working on them.
print "This program converts military time to standard time, and vice versa."
print "Enter times as one number. 12:30=1230 1:00==100"
print "Make sure to enter selection exactly how it is show on screen."
print
#x=0
#timecheck=" "
#mn=" "
timecheck=raw_input("Select one (Military Time/Standard Time): ")
if timecheck==("Military Time"):
x=input("Enter a time: ")
if x>1200:
print "Time: ",x-1200,"O'clock"
if x<1200:
print "Time: ",x+1200,"O'clock"
if timecheck==("Standard Time"):
mn=raw_input("(AM or PM): ")
if mn==("AM"):
x=input("Enter a time: ")
if 1200<=x<=1259:
print "Time: ",x-1200,"Hours"
elif x<1200:
print "Time: ",x,"Hours"
elif x>=1200:
print "Time: ",x+1200,"Hours"
if mn==("PM"):
x=input("Enter a time: ")
if x<=1200:
print "Time: ", x+1200,"Hours"