Difference between revisions of "CSC103: DT's Notes 1"
Line 492: | Line 492: | ||
This all should start sounding familiar and "logical" by now. In fact, we use the same logic when searching for information on the Web, or at the library. For example, assume we are interested in searching for information about how to write a ''class construct'' in the language ''Python''. You could try to enter '''Python class''', which most search engine will internally translate as a search for "Python '''and''' class". Very likely you might find that the results include references to python the animal, not the programming language. So to prevent this from happening we can specify our search as ''python and class and (not snake)''. | This all should start sounding familiar and "logical" by now. In fact, we use the same logic when searching for information on the Web, or at the library. For example, assume we are interested in searching for information about how to write a ''class construct'' in the language ''Python''. You could try to enter '''Python class''', which most search engine will internally translate as a search for "Python '''and''' class". Very likely you might find that the results include references to python the animal, not the programming language. So to prevent this from happening we can specify our search as ''python and class and (not snake)''. | ||
− | Back to the alarm example. Assume that we have the same ''a'' and ''b'' boolean variables as previously, | + | Back to the alarm example. Assume that we have the same ''a'' and ''b'' boolean variables as previously, one that is true on Saturdays only and one that is true on Sundays only. How could we make this alarm go off for any weekday and not on weekends? We could simply say that we want the opposite of the alarm we had to see if we can stay in bed on weekends. So that would be '''not''' ( ''a'' '''or''' ''b'' ). |
For completeness we should show the truth table for the not operator. It's pretty straightforward, and shown below: | For completeness we should show the truth table for the not operator. It's pretty straightforward, and shown below: |
Revision as of 07:37, 5 September 2013
--© D. Thiebaut 08:10, 30 January 2012 (EST)