Question
Q4: Light Switch The MCS Faculty has taken it upon themselves to redesign the computer science labs in Deerfield Hall. Unfortunately, theyre all computer scientists
Q4: Light Switch
The MCS Faculty has taken it upon themselves to redesign the computer science labs in Deerfield Hall. Unfortunately, theyre all computer scientists and love a good logic problem. Theyve decided to redesign the lightswitches such that there are three inputs to one lightbulb! Theyve put a sign up beside the new light switches to help students figure out how to turn the lightbulb on and off.
Given three booleans, use the given logic table below and boolean operators to create a program that outputs either ON or OFF.
Filename
Your filename for this question must be q4.py.
Input
- Three lines, each containing either a 0 or a 1.
Output
- Either ON or OFF on a single line, with no other output.
Algorithm
Use the following logic table to create a program that uses boolean operators to switch the light ON or OFF.
Input 1 | Input 2 | Input 3 | Light |
---|---|---|---|
0 | 0 | 0 | OFF |
0 | 0 | 1 | OFF |
0 | 1 | 0 | OFF |
0 | 1 | 1 | ON |
1 | 0 | 0 | OFF |
1 | 0 | 1 | ON |
1 | 1 | 0 | ON |
1 | 1 | 1 | ON |
Sample Input 1
0 1 0
Sample Output 1
OFF
Sample Input 2
1 1 0
Sample Output 2
ON
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started