Booleans and if else statements


If I use the booleans variables, for t or f how can I add if else statements to make something like a simple light switch?


what do you mean? you could do something like:

light_on = True
if light_on:
    print "The light is on"
    print "The light is off"

light_on = False
if light_on:
    print "The light is on"
    print "The light is off"


I’m trying to make it make sence by using a real life example… If it the light is one it will print the light is on on a screen? But how could I use to make something more tangable than coding for digital reasons. An actual light that can be turned on by a code I uploaded to my phone or something.


do you think you have reached the level yet to handle this?

Well, you will need a piece of hardware which can actually flip the switch, or send an electrical signal to turn the light on or off. But this hardware, not software part of such a project.

Its then easier to make a android app which allows you to turn off/on the flashlight on your mobile phone, but then again, are you ready for this? You need a solid basic understanding before you can work on this

if you really want to make something tangable from the get go, start html and css so you can make webpages which you can publish


If you are looking to tinker with electronics and programming, an arduino starter kit might be of interest (will cost you a bit though)

Phones, you’ll probably be dealing more with IDE’s, permissions, packaging, than with an actual light. You’ll need to already be a decent programmer. On the upside it’s hardware that you already have, and that a lot of other people have.


I am not at the point where I can make sense of variables. I just don’t know what to think at this point!!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.