Entropia:Sandkasten: Unterschied zwischen den Versionen

aus dem Wiki des Entropia e.V., CCC Karlsruhe
Wechseln zu: Navigation, Suche
K
Zeile 19: Zeile 19:
 
     print 'Unknown, AFK or sleeping!'
 
     print 'Unknown, AFK or sleeping!'
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Test test.
 
  
 
{{Youtube|id=0CwkyJA_Crs}}
 
{{Youtube|id=0CwkyJA_Crs}}
 
[[Datei:Binarytreetest.png|200px]]
 

Version vom 30. November 2012, 15:53 Uhr

from time import localtime
 
activities = {8: 'Sleeping',
              9: 'Commuting',
              17: 'Working',
              18: 'Commuting',
              20: 'Eating',
              22: 'Resting' }
 
time_now = localtime()
hour = time_now.tm_hour
 
for activity_time in sorted(activities.keys()):
    if hour < activity_time:
        print activities[activity_time]
        break
else:
    print 'Unknown, AFK or sleeping!'