Ask coding questions

← Back to all posts
HELP PLZzZzZzZzZzZzZzZ!
Dominicl645 (428)

i have no clue on how to work the time module in python. if someone can please explain thoroughly on how to work it and help me with this one part, it will be greatly appreciated! here is what i need help with:
2.Create a ‘time’ variable containing the time 8:45:01:000150 PM
24 Hour time
Import time from datetime
Create the variable t2 and assign time with hour, minute, second and microseconds
3.Print the hour only contained in t3
from datetime import time
t3 = time(hour = 15, minute = 10, second = 0)
4.Modify t3 to 4:10 PM given:
t3 = time(hour = 15, minute = 10, second =0)
print t3
like i said, i have no clue on how to work with the time module, and that include the datetime module as well. Yall pls help me.

Answered by RYANTADIPARTHI (3281) [earned 5 cycles]
View Answer
Commentshotnewtop
Dominicl645 (428)

yall any help would be greatly appreciated. i am new to using the datetime and time modules

RYANTADIPARTHI (3281)

@dominicl645 here:

import time

start = time.time()
end = time.time()

total = start - end

print(total)
Dominicl645 (428)

but can you explain to me how i would use the time module?please, cause thats all im working with in my next unit for my python programming class, and i would really like to know how i would use it incase i run into another problem, and also i dont want people to think that i am letting other people do my homework too. @RYANTADIPARTHI

Dominicl645 (428)

thx. i just looked at it and it is so confusing. is there a way you could simplify it? @RYANTADIPARTHI

RYANTADIPARTHI (3281)

@dominicl645 just follow the directions. If you want to stop something:

time.sleep(1)

if you want seconds:

start = time.time()
print(start)

And that's the basic. Read the link for more.

Dominicl645 (428)

no offence, ik how to what to do if u helped me. im going to keep it open so i can see what other people have to say first. imma give some other people a chance too. @RYANTADIPARTHI

Dominicl645 (428)

but dude, thx tho. for the help imma upvote all ur comments, but i want to see what other people have to say first, you know what i mean? i want to give other people a chance before i select an answer. @RYANTADIPARTHI

Dominicl645 (428)

np. i just dont want to seem like the kind of person who doesnt give anyone else a chance, you know? @RYANTADIPARTHI

Dominicl645 (428)

thx for understanding man. if no one else helps me, then u got the answer and upvotes too. @RYANTADIPARTHI

Dominicl645 (428)

hey, how do you get 'p.m' and 'a.m' to show up using the time module? @RYANTADIPARTHI

RYANTADIPARTHI (3281)

@dominicl645 you can't do that in the time module. but you can in datetime module:

from datetime import datetime 
print(datetime.today().strftime("%p")
Dominicl645 (428)

ah thx for the clarification. and the help. @RYANTADIPARTHI

Dominicl645 (428)

nah not yet. should i start pinging people? @RYANTADIPARTHI

RYANTADIPARTHI (3281)

@dominicl645 no, that's bad. people get mad for that.

Dominicl645 (428)

yeah. at least you cared to help me. i really appreciate it. :) @RYANTADIPARTHI