DISCLAIMER This is not an actual light switch. It is simply a beginner's Python project I made
lighty, lighty, are you on?
Basically, there is a
smart light switch. It determines whether it is day or night, and if it is day it turns off. If it is night, it turns on. Simple? Yes. Boring? Yes. Complete? No. If you'd like to actually create a light switch - just the animation - go on. Me, I just started learning Python. I'll probably update this when I get time (read: learn how to draw/animate the light switch).
is_night no longer exists. The
ifs all run on the
light_on function.To turn the light on and off, use the
Some suggestions, I guess...
would work too, I think, because is_night is true. It also looks slightly more readable to a human.
Yeah, I think what I meant was something like this
is_day = True light_on = not is_day # light_on is already true, so we don't need to compare it to True if light_on: print("The light is on!") print("And is it daytime?") print(is_day) # Similar thing here, but you can use the not keyword to negate it if not light_on: print("The light is off!") print("And is it daytime?") print(is_day)