This is my first project in Python and I am trying to make a study reminder that will tell me to swap between passive and active learning and I hope to further on make it respond to input though an interface, but for now I want to use time.localtime(time.time()) to get hold of the timestamp, the integer that is the even/uneven hour of the now. I could just look at the clock but this is meant to give me some kind of output like two different colours but mot important be my training platform. So how can I get hold of integers thru time. I´ve been trying some different ideas.
Well this code is fragmented but anyway this is where I´m at right now. This is some combo of a function and a list that is not ready at all, it´s only fragments of different tests.
These are techniques I´ve looked into but I have not been able to make any of it pull anything from any time module that I´ve tried. Maybe It has just not been visible/ printed.
Booleans
if/else
if num % 2 == 0: pass # Even else:
pass # Odd
Python Conditions and If statements Python supports the usual logical conditions from mathematics: * Equals: a == b * Not Equals: a != b * Less than: a < b * Less than or equal to: a <= b * Greater than: a > b
* Greater than or equal to: a >= b
import datetime
print ("Current date and time: " , datetime.datetime.now())
def time_even_or_uneven():
if datetime.datetime.now % 2 == 0:
print("Number is even")
else:
print("Number is odd")
This is where my questions start
Uncomplete test code
I´m trying to find a way to start off a function and later on several # functions from the timestamp I get from the code above.
print(datetime.datetime.now % 2 = 0)
import datetime... File "", line 12 print(datetime.datetime.now % 2 = 0) ^ SyntaxError: keyword can't be an expression
Without the faulty line I get the time stamp from the time module:
Current date and time: 2019-07-04 13:58:15.811722
I don´t see anything from the function "time_even_or_uneven"
Aucun commentaire:
Enregistrer un commentaire