As a newbie programmer

The light Switch @ Dcoder

Dcoder icon

Problem: There is a light bulb on the stairs, which has two switches. The light turns on if and only if one of them is on(binary 1) and other is off(binary 0).You are given combinations of these switch find whether the bulb glow or not?

Input: Two bits a and b separated by space, each representing a switch position,(0=off , 1=on)

Output: Print 1 if bulb will turn on else print 0.

Constraints: a=b=0/1

Sample Input: 1 1

Sample Output: 

0

a, b = map(int, input().split())
print(a^b)

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x Publish0x

Reward the author with $0.01 in crypto, and earn yourself as you read!

20% to author / 80% to me.
Rewards are FREE. Publish0x pays them, not you.

Page not displaying correctly?