Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Is there something like a 'maybe' in computer logic?

It is safe to assume that any kind of logic in a computer program must always be either true or false, right? Is there some kind of intermediate between True and False? Like, a maybe?

I'd say that 'maybe' is comprised of the logic that 'leads up to' the final True or False. So that the 'final question' in a program is always starting with 'maybe' and the process of how information is evaluated throughout the program makes the maybe either True or False in the end. If that makes any sense :)

Would you say that this is correct? Or is there no such thing as maybes in programming? What about on an 'conceptual' level? Would this interpretation of maybes be OK to teach someone about logic in computer science? If not, why? Would it add confusion?

https://en.wikipedia.org/wiki/Three-valued_logic has some mention of SQL. an article at http://whatis.techtarget.com/definition/trinary mentions a 3 state concept but then says "Trinary logic is not often used. Binary logic, in which there are only two states represented by 0 and 1, is the most common in computer science and electronics." (or maybe i'm misunderstanding the question.)

Thanks Simon, i'll check those links!

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The only conceptual thing I know that might correlate to a "maybe" in computer logic would be Artificial Intelligence. And I know very little about that. As I understand it, decisions are made by the computer based on a number that is generated between 0 and 1, but one not being inclusive.

In general, no, I don't think we really have "maybe"s in computer logic. And if you ever get a chance, you might take discrete mathematics or possibly a beginning electrical engineering course. When we operate a computer we are quite literally just flipping a bunch of switches. And these switches are either "on" or "off". If the switch is "on" it's a 1. If the switch is "off" it's a 0. This is why computers use binary and why you've forever heard that computers operate on 0's and 1's. That's how the state of the switch is represented at the electrical level.

I hope this helps! :sparkles:

Very interesting points, i guess that since programmers need to account for all possibilities and 'create' the logic in a program no room is left for the computer to make choices. What i am saying is that all 'leeway' has been put inside constraints enforced by the programmer which a 'normal' computer is not able to operate outside of. Thus, True or False are the only options. Steven brings up a very interesting point though, that of a null object. I would argue that the null object is a container for an 'unaccounted' (false) action that has been predetermined to be 'evaluated for'. Thus the concept of null objects being a sort-of-a maybe falls in my opinion. What are your thoughts on this ? Steven Parker and Jennifer Nordell ? As Steven highlighted, would you say that "i don't know" is the same thing as 'maybe' ?

Ops! Sorry, i made a misstake. I've fixed that typo now. I meant you Steven. Sorry for the confusion.

Any thoughts on my comment otherwise Steven Parker ?

Steven Parker
Steven Parker
243,318 Points

Are we talking about hardware, or software?

At the hardware level, most computers are essentially large collections of switches as Jennifer described. But in software, the concept of representing multiple states is very common, and just what the states are will depend on what it is that is being represented in the program.

But you would also need to determine what "maybe" represents. In most cases, "maybe" is not an actual state but an admission of insufficient information to make a determination or decision. The concept of "I don't know" is often indicated in computers by a "null" value. This value is actually stored as an alternative to "true" or "false", so it might be considered to mean "maybe". Whether it is used by the logic to produce a result, or just used to indicate that the result process needs to be deferred to a later time depends on the program.

Thank you so much for your response Steven, i posted my full response as a reply to Jennifers answer.