{"kind":"Notebook","sha256":"ca877bc8b10839ca5579ffe737c3d2e7de73a663a09c049720cc234fe093e210","slug":"binary-code","location":"/release/Lab1/Binary_Code.ipynb","dependencies":[],"frontmatter":{"title":"Binary Code","kernelspec":{"name":"python3","display_name":"Python 3 (ipykernel)","language":"python"},"authors":[{"nameParsed":{"literal":"Chung Chan","given":"Chung","family":"Chan"},"name":"Chung Chan","affiliations":["City University of Hong Kong"],"id":"contributors-myst-generated-uid-0"}],"github":"https://github.com/dive4dec/cs1302_24a","keywords":[],"affiliations":[{"id":"City University of Hong Kong","name":"City University of Hong Kong"}],"thumbnail":"/~ccha23/cs1302_24a/build/3d4a19c8f86b615868b73d677475d179.svg","exports":[{"format":"ipynb","filename":"Binary_Code.ipynb","url":"/~ccha23/cs1302_24a/build/Binary_Code-667fd825c42e4e2cb9b0d09d66d57f40.ipynb"}]},"mdast":{"type":"root","children":[{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Welcome to this lab where you will explore how computers represent numbers using a fun card-guessing game! Through this lab, you will gain an understanding of how binary numbers are used to represent decimal numbers in computers.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"mmqzuOgtYS"}],"key":"qksRxnDZfR"}],"key":"IAJBtH5JWd"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"heading","depth":2,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Card Guessing Game","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"VR5hh089Oc"}],"identifier":"card-guessing-game","label":"Card Guessing Game","html_id":"card-guessing-game","implicit":true,"key":"Qmim3AZ4S6"}],"key":"xlv9gSuM61"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"subslide"}},"children":[{"type":"heading","depth":3,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Rules","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"AxOL20pG9a"}],"identifier":"rules","label":"Rules","html_id":"rules","implicit":true,"key":"Xh3H0WNSdi"}],"key":"r8V0j9GX86"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"fragment"}},"children":[{"type":"container","kind":"table","children":[{"type":"caption","children":[{"type":"paragraph","children":[{"type":"captionNumber","kind":"table","label":"tab:deck","identifier":"tab:deck","html_id":"tab-deck","enumerator":"1","children":[{"type":"text","value":"Table ","key":"caCgcofuWX"},{"type":"text","value":"1","key":"Wv9fyG0sg9"},{"type":"text","value":":","key":"cK880RECK4"}],"template":"Table %s:","key":"hUj9WrtqM0"},{"type":"text","value":"Deck of cards","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"xKxujRMHMM"}],"key":"o34YXYeiGI"}],"key":"P0vuYLCTLI"},{"type":"table","style":{"width":"100%"},"children":[{"type":"tableRow","children":[{"type":"tableCell","header":true,"children":[],"key":"ZIjO4JR0Dd"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"1","key":"hkYAOlgeBU"}],"key":"PqqOYw9WZd"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"2","key":"uQib92OU7O"}],"key":"lG4G6E0avz"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"3","key":"Ebz9XyJFFH"}],"key":"liAoDAsqve"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"4","key":"QyYVMDCyKI"}],"key":"DR4n5rtzAO"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"5","key":"sPW2FZANLq"}],"key":"gRDnqenWlR"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"6","key":"Yq0XG0gw2g"}],"key":"YY1qGLTFvF"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"7","key":"a5rzEMJP8x"}],"key":"unqtifyNsF"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"8","key":"Cl0pBe7fGU"}],"key":"T0rewnWq14"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"9","key":"FXsLmXDUF4"}],"key":"YIwYUjwKYf"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"10","key":"h2kRZ3rMiz"}],"key":"X00eeUPVI0"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"J","key":"l6uXKRfeZk"}],"key":"Yt3Z8lbKAu"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"Q","key":"p0oQHofX8n"}],"key":"QCImhlU2MY"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"K","key":"GDsJpd4cmf"}],"key":"Qiyn2hMVoj"}],"key":"nJYnEM8G2f"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"Diamond","key":"vEpzr0akHw"}],"key":"hvn0dKwzYb"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/3d4a19c8f86b615868b73d677475d179.svg","alt":"A-Diamond","key":"UUuQHPSzdg","urlSource":"https://upload.wikimedia.org/wikipedia/commons/e/e9/Cards-A-Diamond.svg"}],"key":"lymawGMFfW"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/f3ba9c26b6410949796fb3e38755cd86.svg","alt":"2-Diamond","key":"rQybobmiar","urlSource":"https://upload.wikimedia.org/wikipedia/commons/9/99/Cards-2-Diamond.svg"}],"key":"xv3p02Gfy1"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/baa5c526a0710d182ed3541d9dd9818f.svg","alt":"3-Diamond","key":"BpTuIu38D2","urlSource":"https://upload.wikimedia.org/wikipedia/commons/4/44/Cards-3-Diamond.svg"}],"key":"lCRp2iyr9o"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/bd191f58edf22dff7a98a95f00faefa8.svg","alt":"4-Diamond","key":"x8X5jDuGuk","urlSource":"https://upload.wikimedia.org/wikipedia/commons/a/af/Cards-4-Diamond.svg"}],"key":"evBTTMRxZu"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/eabf676478505b050bd7e3832ece0545.svg","alt":"5-Diamond","key":"vdB1aqPfru","urlSource":"https://upload.wikimedia.org/wikipedia/commons/d/dd/Cards-5-Diamond.svg"}],"key":"bhcbM3QR7O"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/79a21d91949c86501acdcf3ec16bf65c.svg","alt":"6-Diamond","key":"ilkFQr7L5T","urlSource":"https://upload.wikimedia.org/wikipedia/commons/4/44/Cards-6-Diamond.svg"}],"key":"CsSvHEB1OP"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/4f9ed1a59619b7715ef0cf9c32053194.svg","alt":"7-Diamond","key":"Acl6qAEHBz","urlSource":"https://upload.wikimedia.org/wikipedia/commons/2/2b/Cards-7-Diamond.svg"}],"key":"CKXNx08LfJ"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/cb8e331a8f1910cfe4bc91fd692a9a15.svg","alt":"8-Diamond","key":"df6XTC8XlE","urlSource":"https://upload.wikimedia.org/wikipedia/commons/9/90/Cards-8-Diamond.svg"}],"key":"G3UDKjBq4N"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/010d7a0c6e7f2bd7ba8f796d9c4f1e4d.svg","alt":"9-Diamond","key":"rWySszBK9n","urlSource":"https://upload.wikimedia.org/wikipedia/commons/2/25/Cards-9-Diamond.svg"}],"key":"n9JIKdivvW"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/7cca322b20ef7fadf56ad1ef31738898.svg","alt":"10-Diamond","key":"PN97zgAvB5","urlSource":"https://upload.wikimedia.org/wikipedia/commons/c/c2/Cards-10-Diamond.svg"}],"key":"dx816XPyct"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/12bb388a7c0593eba292be225abdc754.svg","alt":"J-Diamond","key":"irB4hzlNMu","urlSource":"https://upload.wikimedia.org/wikipedia/commons/7/78/Cards-J-Diamond.svg"}],"key":"Asjl0yw6Vr"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/e2daa0bd043372aca7bd34f9ec8c52bc.svg","alt":"Q-Diamond","key":"k1HDyzXMoh","urlSource":"https://upload.wikimedia.org/wikipedia/commons/c/c3/Cards-Q-Diamond.svg"}],"key":"PhwnNplBxr"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/241cd7a2e916d4adbceb01b863690a93.svg","alt":"K-Diamond","key":"IaWn8d2hGg","urlSource":"https://upload.wikimedia.org/wikipedia/commons/5/55/Cards-K-Diamond.svg"}],"key":"qKU1H5G41a"}],"key":"bJbCrO5Jqd"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"Club","key":"FUT8mexh1P"}],"key":"ZxaGLGcpJ7"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/1bb1a83f9f3441af96a2a2f5cbd09b55.svg","alt":"A-Club","key":"TtpQZ9Gg08","urlSource":"https://upload.wikimedia.org/wikipedia/commons/c/c4/Cards-A-Club.svg"}],"key":"D41dsc5UFX"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/a3069fef31144bb4600add17878056e4.svg","alt":"2-Club","key":"tQS294ufLh","urlSource":"https://upload.wikimedia.org/wikipedia/commons/b/b0/Cards-2-Club.svg"}],"key":"enV0U0erBU"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/4a2684e691d877e3d0bfff97f1351780.svg","alt":"3-Club","key":"R6EfB1W4Fc","urlSource":"https://upload.wikimedia.org/wikipedia/commons/e/e0/Cards-3-Club.svg"}],"key":"MPNWgkljVI"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/de0e9fb50014dd729b1427b82bf37cfc.svg","alt":"4-Club","key":"kMwgJ7AAes","urlSource":"https://upload.wikimedia.org/wikipedia/commons/6/69/Cards-4-Club.svg"}],"key":"EswNYCqMQd"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/e841075722f39daf96292c987b33e430.svg","alt":"5-Club","key":"pOUjn9FiKu","urlSource":"https://upload.wikimedia.org/wikipedia/commons/7/7e/Cards-5-Club.svg"}],"key":"uVpX4emC4I"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/4067b5b3fc538b839fdb1876fc92078f.svg","alt":"6-Club","key":"Mj6PThcAKF","urlSource":"https://upload.wikimedia.org/wikipedia/commons/a/af/Cards-6-Club.svg"}],"key":"EzpdV7oq55"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/c5e0b0cec4541b8f7b29c040bfa56c0a.svg","alt":"7-Club","key":"XW0dIKbrmq","urlSource":"https://upload.wikimedia.org/wikipedia/commons/8/8e/Cards-7-Club.svg"}],"key":"XYl8yf4WsP"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/5976d2ff96645f0683986f39ff66201c.svg","alt":"8-Club","key":"uejYqBvoIr","urlSource":"https://upload.wikimedia.org/wikipedia/commons/f/fd/Cards-8-Club.svg"}],"key":"RgWOALSDaI"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/c787ceef17b9007ad462aead73ac97d6.svg","alt":"9-Club","key":"TYX1dYSRu3","urlSource":"https://upload.wikimedia.org/wikipedia/commons/a/ac/Cards-9-Club.svg"}],"key":"tAdRMXEzOo"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/6a84b7b1849090289503eae6b74c86cb.svg","alt":"10-Club","key":"QDLAcnztr9","urlSource":"https://upload.wikimedia.org/wikipedia/commons/2/25/Cards-10-Club.svg"}],"key":"f46JMncXUk"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/6064c70776bb344712863810e8f77eb9.svg","alt":"J-Club","key":"etpHl1DIIh","urlSource":"https://upload.wikimedia.org/wikipedia/commons/c/c7/Cards-J-Club.svg"}],"key":"qY8arWIcNc"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/ff2cc138bcb575d0e07d8cd66c946bbb.svg","alt":"Q-Club","key":"PLxBpHaFIR","urlSource":"https://upload.wikimedia.org/wikipedia/commons/3/37/Cards-Q-Club.svg"}],"key":"SuQxw6oRbb"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/3d68cdc06d3bbe14531ea50a67f548fb.svg","alt":"K-Club","key":"MCqqRpWUeC","urlSource":"https://upload.wikimedia.org/wikipedia/commons/9/9e/Cards-K-Club.svg"}],"key":"nxOBCqScNe"}],"key":"U7fZ5fDpiZ"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"Heart","key":"qLHKQY8mwE"}],"key":"iM1Jkd9cDy"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/2a2937e4616eb06ee26d24bbea22b3b8.svg","alt":"A-Heart","key":"qEzW5TItGU","urlSource":"https://upload.wikimedia.org/wikipedia/commons/6/60/Cards-A-Heart.svg"}],"key":"EpvMyEcs1B"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/1637abcd3717a7c3ef4ca5701b3b76bc.svg","alt":"2-Heart","key":"OzYwRmXogV","urlSource":"https://upload.wikimedia.org/wikipedia/commons/6/6e/Cards-2-Heart.svg"}],"key":"bWvLwuFDOx"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/b75657894e59489713c7d451c7a397ce.svg","alt":"3-Heart","key":"J9crid1yrl","urlSource":"https://upload.wikimedia.org/wikipedia/commons/5/57/Cards-3-Heart.svg"}],"key":"ZKWnZxc6MT"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/597bc465f1b4e9b58a2afc927613bfaa.svg","alt":"4-Heart","key":"Ielc0ENXN1","urlSource":"https://upload.wikimedia.org/wikipedia/commons/3/39/Cards-4-Heart.svg"}],"key":"ESVSAZ63z3"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/378bb6a8b561cf0c318679482311de35.svg","alt":"5-Heart","key":"ZXBjTj1mHY","urlSource":"https://upload.wikimedia.org/wikipedia/commons/9/91/Cards-5-Heart.svg"}],"key":"qxFEmiAEP8"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/ef1be8ed22c740b7d7a0fbc871b29f67.svg","alt":"6-Heart","key":"xWleGioo7b","urlSource":"https://upload.wikimedia.org/wikipedia/commons/5/55/Cards-6-Heart.svg"}],"key":"B48KE4wGqx"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/4dc60587e5ae09606e5198f69c6ba28f.svg","alt":"7-Heart","key":"Ywjv39uwu1","urlSource":"https://upload.wikimedia.org/wikipedia/commons/d/d4/Cards-7-Heart.svg"}],"key":"cE57WpV9vA"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/06945f22b6ed8cfd5370bfc81a1eeafa.svg","alt":"8-Heart","key":"qLppCdQRkn","urlSource":"https://upload.wikimedia.org/wikipedia/commons/5/55/Cards-8-Heart.svg"}],"key":"eBmaQuMWe7"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/9b4e285ca66fbad53492eb61e063291c.svg","alt":"9-Heart","key":"uNuixdVEuj","urlSource":"https://upload.wikimedia.org/wikipedia/commons/d/d2/Cards-9-Heart.svg"}],"key":"J2HM5QxMAB"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/57456843e1ca85d5abb36749e2a7ab41.svg","alt":"10-Heart","key":"x8AxoOfQLt","urlSource":"https://upload.wikimedia.org/wikipedia/commons/7/76/Cards-10-Heart.svg"}],"key":"SCI3mjMQ5N"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/b6652885c577c24c3c08346fd5334902.svg","alt":"J-Heart","key":"R9Uw0dewCJ","urlSource":"https://upload.wikimedia.org/wikipedia/commons/e/e7/Cards-J-Heart.svg"}],"key":"a6qXycSYZm"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/a1cd2014ef6b374c1825e5d1e921b622.svg","alt":"Q-Heart","key":"SGZjSXSCoA","urlSource":"https://upload.wikimedia.org/wikipedia/commons/2/28/Cards-Q-Heart.svg"}],"key":"v3F4chI5kw"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/d0960fed6f9c7f5e341f14e28b47cc00.svg","alt":"K-Heart","key":"rGxYecG9Ms","urlSource":"https://upload.wikimedia.org/wikipedia/commons/b/bf/Cards-K-Heart.svg"}],"key":"ajOLhTdj6c"}],"key":"Z7DlJ4DVtk"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"Spade","key":"hONSr37ps1"}],"key":"CLDFZpmWyu"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/bd136b8af7fe5c43f830a2e5ccf4ccf2.svg","alt":"A-Spade","key":"op7Svtsqir","urlSource":"https://upload.wikimedia.org/wikipedia/commons/9/9d/Cards-A-Spade.svg"}],"key":"JBPbfa5Y5v"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/5fdd9dd3d1b5562635e7dd8e4b104ea7.svg","alt":"2-Spade","key":"i5FH0DntbQ","urlSource":"https://upload.wikimedia.org/wikipedia/commons/e/e7/Cards-2-Spade.svg"}],"key":"ixgLMmx6jc"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/d2106efdbb9f2713d1b9785426ede34c.svg","alt":"3-Spade","key":"sugSObktmG","urlSource":"https://upload.wikimedia.org/wikipedia/commons/d/d0/Cards-3-Spade.svg"}],"key":"zRUT6bawlL"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/f8c7b95379250d9ab38b964df6376d45.svg","alt":"4-Spade","key":"U1N5F5dmXj","urlSource":"https://upload.wikimedia.org/wikipedia/commons/4/4e/Cards-4-Spade.svg"}],"key":"AG6XcEzPS7"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/fe9321909ff627ef43cba0cebdb51ddc.svg","alt":"5-Spade","key":"FKIrAzqhET","urlSource":"https://upload.wikimedia.org/wikipedia/commons/b/b1/Cards-5-Spade.svg"}],"key":"iWBu60kkGa"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/1d5e7cb97c2a211ffa0cf10ce4ca8fac.svg","alt":"6-Spade","key":"sm9JWblosp","urlSource":"https://upload.wikimedia.org/wikipedia/commons/6/68/Cards-6-Spade.svg"}],"key":"rpy9DaEV8O"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/0f1cafdece6abe22ddef1cd14c9d6448.svg","alt":"7-Spade","key":"nevejWOjNJ","urlSource":"https://upload.wikimedia.org/wikipedia/commons/c/c6/Cards-7-Spade.svg"}],"key":"HmPgh3E0Mh"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/edde55e0bf03da50d7f4fde82cbdda6d.svg","alt":"8-Spade","key":"GmcuVgRefJ","urlSource":"https://upload.wikimedia.org/wikipedia/commons/7/7e/Cards-8-Spade.svg"}],"key":"PR3sD98Uoe"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/851d99f9b3697e1b450e0cad75cffa73.svg","alt":"9-Spade","key":"PDMLzb4QD9","urlSource":"https://upload.wikimedia.org/wikipedia/commons/0/0a/Cards-9-Spade.svg"}],"key":"niwnDuJaBa"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/d9998ab8122a5198018a8e023cdf2d36.svg","alt":"10-Spade","key":"sSERixJyGE","urlSource":"https://upload.wikimedia.org/wikipedia/commons/6/67/Cards-10-Spade.svg"}],"key":"Ar9JnRHfs6"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/ced71eb0aa936f133ed74f44018206f7.svg","alt":"J-Spade","key":"FpxTCr8v9a","urlSource":"https://upload.wikimedia.org/wikipedia/commons/e/ea/Cards-J-Spade.svg"}],"key":"EHLLs7BVCd"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/6f659b1a5ebf3bd53272dfa3cb1a1702.svg","alt":"Q-Spade","key":"pISLsAJP02","urlSource":"https://upload.wikimedia.org/wikipedia/commons/e/ef/Cards-Q-Spade.svg"}],"key":"DmzeSpvO2S"},{"type":"tableCell","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/2e9cfbf1df22dd346dd6e0387363c9d4.svg","alt":"K-Spade","key":"k5ynJxefVk","urlSource":"https://upload.wikimedia.org/wikipedia/commons/1/18/Cards-K-Spade.svg"}],"key":"P4HZJLDFn7"}],"key":"nvqEpGhlyT"}],"key":"mFYk49pT57"}],"label":"tab:deck","identifier":"tab:deck","enumerator":"1","html_id":"tab-deck","key":"mUctgG3YLs"}],"key":"mzp7wz4nIE"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"crossReference","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Table ","key":"wcNjc25xak"},{"type":"text","value":"1","key":"wTelbAqDym"}],"identifier":"tab:deck","label":"tab:deck","kind":"table","template":"Table %s","enumerator":"1","resolved":true,"html_id":"tab-deck","key":"qA9Rhkn8sy"},{"type":"text","value":" shows a deck of 52 cards:","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"Dz0BJhugmr"}],"key":"P1FhJ535EM"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":2,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"Each card is in one of the four suits: ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"D2NsGuYNok"},{"type":"emphasis","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"Diamond","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"PqMf6KlCBF"}],"key":"rNON6BaaFr"},{"type":"text","value":" ♦, ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"ogQF7p5hmA"},{"type":"emphasis","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"Club","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"Gr8CCGoqIm"}],"key":"N8tn3yO930"},{"type":"text","value":" ♣, ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"jTLMe9CDdi"},{"type":"emphasis","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"Heart","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"eM60Tm0JAA"}],"key":"ENQAshAttf"},{"type":"text","value":" ♥, and ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"hAgNTJG19S"},{"type":"emphasis","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"Spade","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"HSG5hH5AJs"}],"key":"Y1jB90dViu"},{"type":"text","value":" ♠.","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"Skb6Y9euz2"}],"key":"qIqRWYBYkp"},{"type":"listItem","spread":true,"position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"Each card has a value ranging from 1 to 13. For simplicity, the original card values A, J, Q, and K are converted to the numerical values 1, 11, 12, and 13 respectively.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"IxFmJO3nCM"}],"key":"SbdCh3amYY"}],"key":"r8wctxCDi2"}],"key":"o0uqcUn88v"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"container","kind":"figure","children":[{"type":"image","url":"/~ccha23/cs1302_24a/build/card_game.dio-a985740eea46b6855b58790a2d6b01ff.svg","alt":"A player guesses a card drawn by a dealer.","align":"left","key":"BUd0ghmUu0","urlSource":"images/card_game.dio.svg"},{"type":"caption","children":[{"type":"paragraph","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"captionNumber","kind":"figure","label":"fig:card-guessing","identifier":"fig:card-guessing","html_id":"fig-card-guessing","enumerator":"1","children":[{"type":"text","value":"Figure ","key":"ZRLuqeYOcy"},{"type":"text","value":"1","key":"tInZfhkO4X"},{"type":"text","value":":","key":"vzA5JKb9pk"}],"template":"Figure %s:","key":"pXgcks61ju"},{"type":"text","value":"Card guessing game","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"LP4a06vnGg"}],"key":"dtiHV3fpaZ"}],"key":"mr3G0dXP48"}],"label":"fig:card-guessing","identifier":"fig:card-guessing","enumerator":"1","html_id":"fig-card-guessing","key":"RrhjPILg8N"}],"key":"zcIiMBtadJ"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"card","children":[{"type":"header","children":[{"type":"paragraph","children":[{"type":"text","value":"Rules","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"kgsyfkLIGL"}],"key":"KV9w7hdO40"}],"key":"P0seZZyGZl"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"As depicted in ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"PYKsSGwSoh"},{"type":"crossReference","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"Figure ","key":"odhPSD4Mit"},{"type":"text","value":"1","key":"UUUlNuY5Ld"}],"identifier":"fig:card-guessing","label":"fig:card-guessing","kind":"figure","template":"Figure %s","enumerator":"1","resolved":true,"html_id":"fig-card-guessing","key":"DJgeib2OUo"},{"type":"text","value":", the card-guessing game involves the following steps:","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"rzQDAXXhi9"}],"key":"NvKUEmmbHk"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":6,"column":1},"end":{"line":10,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"text","value":"The dealer selects a card without revealing it to the player.","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"aRstp2YouM"}],"key":"XEN4hdRRj9"},{"type":"listItem","spread":true,"position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"children":[{"type":"text","value":"The player’s goal is to correctly guess the chosen card.","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"uHu3firmau"}],"key":"Qp81OgADwg"},{"type":"listItem","spread":true,"position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"children":[{"type":"text","value":"To make an informed guess, the player can ask up to six yes/no questions.","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"rEyRg93H6H"}],"key":"LHLocAGpx1"},{"type":"listItem","spread":true,"position":{"start":{"line":9,"column":1},"end":{"line":10,"column":1}},"children":[{"type":"text","value":"The dealer must answer each question truthfully and immediately.","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"AsMDJrlBnL"}],"key":"DfaXGaIaoT"}],"key":"FouRGimuad"},{"type":"proof","kind":"example","label":"eg:valid-questions","identifier":"eg:valid-questions","class":"dropdown","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Valid questions","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"NERIUxQZ9x"}],"key":"l1qGGNX7y3"},{"type":"paragraph","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"children":[{"type":"text","value":"For instance, the player may ask:","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"X43AZ2ZTZf"}],"key":"LR8iMFd2qZ"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":16,"column":1},"end":{"line":18,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":16,"column":1},"end":{"line":16,"column":1}},"children":[{"type":"text","value":"Is the suit club?","position":{"start":{"line":16,"column":1},"end":{"line":16,"column":1}},"key":"L13tWlbUet"}],"key":"IpS4aydpKz"},{"type":"listItem","spread":true,"position":{"start":{"line":17,"column":1},"end":{"line":17,"column":1}},"children":[{"type":"text","value":"Is the card diamond 1?","position":{"start":{"line":17,"column":1},"end":{"line":17,"column":1}},"key":"Cl4yawQSeA"}],"key":"gByVSsdqPl"},{"type":"listItem","spread":true,"position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"children":[{"type":"text","value":"Is the value at least 10?","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"lOuNbwQR9U"}],"key":"SGA6UFCgmv"}],"key":"ORl2jitNiB"}],"enumerator":"1","html_id":"eg-valid-questions","key":"ME5WJt0mmo"},{"type":"proof","kind":"example","label":"eg:invalid-questions","identifier":"eg:invalid-questions","class":"dropdown","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Invalid questions","position":{"start":{"line":22,"column":1},"end":{"line":22,"column":1}},"key":"HYLZi3ZQ2T"}],"key":"Gei3qtaIpj"},{"type":"paragraph","position":{"start":{"line":26,"column":1},"end":{"line":26,"column":1}},"children":[{"type":"text","value":"However, the player cannot ask:","position":{"start":{"line":26,"column":1},"end":{"line":26,"column":1}},"key":"liaJNd2FwR"}],"key":"Zh0qHvkXJ3"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":27,"column":1},"end":{"line":29,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"children":[{"type":"text","value":"What is the value?","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"key":"bwchEcdpVH"}],"key":"Mel1QV0p3l"},{"type":"listItem","spread":true,"position":{"start":{"line":28,"column":1},"end":{"line":29,"column":1}},"children":[{"type":"text","value":"What is the suite?","position":{"start":{"line":28,"column":1},"end":{"line":28,"column":1}},"key":"Q00A40kQ2S"}],"key":"rHzYeLisdS"}],"key":"xonW215FGC"},{"type":"paragraph","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"children":[{"type":"text","value":"because the answers are not ","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"TjwQeDMycq"},{"type":"strong","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"children":[{"type":"text","value":"yes/no","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"oDFXhymZVE"}],"key":"wfPJtWRclq"},{"type":"text","value":".","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"aU5LuTJGXS"}],"key":"bl6QBymaV2"}],"enumerator":"2","html_id":"eg-invalid-questions","key":"eE44QfgNLg"}],"key":"QqsK5XCrBk"}],"key":"klgkmdm8Qc"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"One strategy is to ask whether the randomly drawn card is a specific card, e.g.,","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"tcixUdpHv0"}],"key":"SNyf2XSYgq"},{"type":"card","children":[{"type":"paragraph","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"Is it the Diamond 1?","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"nWrglNjrDg"}],"key":"sBGz0oJri3"}],"key":"KlCWo8J2Pz"},{"type":"paragraph","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"children":[{"type":"text","value":"If the answer is yes, the player can confidently guess that the card is Diamond 1 and win the game. However, if the answer is no, the player can continue to check another card, e.g.,","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"IErhcdbXqm"}],"key":"QG7FU50ARP"},{"type":"card","children":[{"type":"paragraph","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"text","value":"Is it the Diamond 2?","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"tQ2MpG85Vy"}],"key":"xqqzfT2SuU"}],"key":"b5YPD4xvAY"},{"type":"paragraph","position":{"start":{"line":17,"column":1},"end":{"line":17,"column":1}},"children":[{"type":"text","value":"and so on...","position":{"start":{"line":17,"column":1},"end":{"line":17,"column":1}},"key":"cwCs211mrj"}],"key":"u8D1sXm4S4"}],"key":"bwKHmT9BeE"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"A ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"bS5LafN5wV"},{"type":"crossReference","label":"pseudocode","identifier":"term-pseudocode","kind":"definitionTerm","children":[{"type":"text","value":"pseudocode","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"auMHg26LWT"}],"template":"{name}","resolved":true,"html_id":"term-pseudocode","key":"rDkyfVjnp8"},{"type":"text","value":" that summarizes the above strategy (or ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"aEXxDnVk4z"},{"type":"crossReference","label":"algorithm","identifier":"term-algorithm","kind":"definitionTerm","children":[{"type":"text","value":"algorithm","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"NUdp7jFmvu"}],"template":"{name}","resolved":true,"html_id":"term-algorithm","key":"qOFktnH2Z6"},{"type":"text","value":") is shown below.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"r46RF6opx8"}],"key":"egABV5XVh5"}],"key":"ZbWKjy1U8a"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"proof","kind":"algorithm","label":"code:1-by-1","identifier":"code:1-by-1","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Checking one card at a time","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"vOM0zqmTzQ"}],"key":"KtDuwmotvF"},{"type":"code","lang":"python","emphasizeLines":[3,4],"showLineNumbers":true,"value":"while the number of questions asked < 6 and \\\n      the correct card has not been guessed yet:\n    randomly pick a new card not chosen before\n    ask the dealer whether the drawn card is the chosen one\n    if the answer is yes:\n        guess the card\n    else:\n        increment the number of questions asked","key":"myiVaSZOeb"}],"enumerator":"1","html_id":"code-1-by-1","key":"BCkNIFssOf"}],"key":"XKLyB1r0QA"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"exercise","label":"ex:chance","identifier":"ex:chance","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"chance","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"Ee24FzlJPh"}],"key":"BzHxwt33TS"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"What is the chance of winning using the strategy in ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"WPEZikCtUk"},{"type":"crossReference","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"Algorithm ","key":"Q9K4d15syR"},{"type":"text","value":"1","key":"IvkqCd2WS7"}],"identifier":"code:1-by-1","label":"code:1-by-1","kind":"proof:algorithm","template":"Algorithm %s","enumerator":"1","resolved":true,"html_id":"code-1-by-1","key":"bKKP62MWMi"},{"type":"text","value":"?","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"hhbXB8d1oJ"}],"key":"AYziT3LhYH"},{"type":"admonition","kind":"attention","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Attention","key":"p0etDZW0VK"}],"key":"MDeay93eVn"},{"type":"paragraph","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"children":[{"type":"text","value":"Provide your answer in the following code cell by assigning a fraction to the variable ","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"EvnIFXVXvf"},{"type":"inlineCode","value":"chance","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"Y8dnRcsxzx"},{"type":"text","value":" such as","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"iUlb5GVtEY"}],"key":"XmrbUd6H5n"},{"type":"code","lang":"python","value":"chance = 0.5","position":{"start":{"line":9,"column":1},"end":{"line":11,"column":1}},"key":"PTh26xqCF4"},{"type":"paragraph","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"text","value":"where the value 0.5 means 50% chance. This is just a demo, i.e., 50% is ","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"nS5NyVRs3L"},{"type":"emphasis","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"text","value":"not","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"zN6dpvyEYZ"}],"key":"gLv5EU87nL"},{"type":"text","value":" necessarily the correct answer. Your answer should be accurate at least up to ","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"AGYV3nj2AI"},{"type":"emphasis","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"text","value":"2 decimal places","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"LlWeeocecv"}],"key":"qO6w2V88yN"},{"type":"text","value":".","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"Vetontlq5Y"}],"key":"Tp7BnuZ28o"}],"key":"IVwDl7y2T3"}],"enumerator":"1","html_id":"ex-chance","key":"Jscw6qKukj"}],"key":"YPopNVjSNi"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"nbgrader":{"cell_type":"code","checksum":"a897b9d3697bb3e5aa85893fe5b73157","grade":false,"grade_id":"chance","locked":false,"schema_version":3,"solution":true,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# YOUR CODE HERE\nraise NotImplementedError","key":"ilsKp95X6z"},{"type":"output","id":"bXlMIPrk1FVrfVoXWwy8Y","data":[],"key":"fdWHREr8rv"}],"key":"bYW1b1TOmL"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"admonition","kind":"tip","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Tip","key":"qBg7yhEmOz"}],"key":"uxs87Y7qAi"},{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"Run the following visible tests to check whether the ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"uKEhHyF6M1"},{"type":"inlineCode","value":"chance","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"y7EUe34WmZ"},{"type":"text","value":" variable meets the following criteria:","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"tV9R1GC4Iw"}],"key":"KZYU0Dd2wi"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":5,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"It is greater than or equal to 0.","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"Q9UbDxjWnS"}],"key":"l1j3xygw1q"},{"type":"listItem","spread":true,"position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"text","value":"It is less than or equal to 1.","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"K18h7Ri6pL"}],"key":"ZsnJReHjDB"}],"key":"WFZDqNqPyb"}],"key":"whdIcq4Cfz"}],"key":"Ob3UsNOJY9"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"18833ca8b32ec87f1070f52783b0563b","grade":true,"grade_id":"test-chance","locked":true,"points":1,"schema_version":3,"solution":false,"task":false},"slideshow":{"slide_type":""}},"children":[{"type":"code","lang":"python","executable":true,"value":"# tests\nassert chance >= 0\nassert chance <= 1","key":"roDwenb5cA"},{"type":"output","id":"nuZm31W5oLmhBcy01eqTk","data":[],"key":"wXFo6GjkxH"}],"key":"RBn8JVVsay"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"admonition","kind":"caution","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Caution","key":"sDt9xO2A3Q"}],"key":"u4PEebbjZI"},{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"Passing the visible tests does not guarantee that the answer is correct. The actual correctness will be evaluated using a hidden test to be injected into the following cell.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"sACL4OG1Dp"}],"key":"NiVnynIo56"}],"key":"N3Wo2BfwTK"}],"key":"IKm8EmK1p8"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"7fb5b29aece1c133906b690128e5f9f2","grade":true,"grade_id":"htest-chance","locked":true,"points":1,"schema_version":3,"solution":false,"task":false},"slideshow":{"slide_type":""}},"children":[{"type":"code","lang":"python","executable":true,"value":"# hidden tests","key":"cD1eKB7EOY"},{"type":"output","id":"tVfbuNvPUrJ0CM-Mf-RwB","data":[],"key":"LvrUYioE7U"}],"key":"eV82nTIFK2"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"heading","depth":3,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Virtual Cards","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"ajl8GYIzJu"}],"identifier":"virtual-cards","label":"Virtual Cards","html_id":"virtual-cards","implicit":true,"key":"YS7HOUinwx"}],"key":"eEvfnRyNN0"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Instead of drawing a physical card, the dealer can use programming to generate a virtual deck and draw a ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"WRo6ybCV6O"},{"type":"emphasis","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"random","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"EYc8cECRYm"}],"key":"ILCvLHMX4o"},{"type":"footnoteReference","identifier":"pseudorandom","label":"pseudorandom","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"number":1,"enumerator":"1","key":"X1PxrVQT6o"},{"type":"text","value":" virtual card from it. Run the code below to get the required tools.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"qTQ81Rv9Ih"}],"key":"C0vY1nu2jh"},{"type":"footnoteDefinition","identifier":"pseudorandom","label":"pseudorandom","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"The truth is, the random generation process will look random but is not truly random. You will learn about this pseudorandomness later in the course.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"NMZQKu6TnG"}],"key":"ygoAhnPXzn"}],"number":1,"enumerator":"1","key":"B7KRGVrMgX"}],"key":"ZHrHw4Vf0s"},{"type":"block","kind":"notebook-code","data":{},"children":[{"type":"code","lang":"python","executable":true,"value":"from collections import namedtuple  # for naming the cards\nfrom random import choice  # for randomly drawing cards","key":"CvFAdWMd3C"},{"type":"output","id":"8koBlahdJwMc20fkMqzwd","data":[],"key":"iktHeY8x8G"}],"key":"S3YS4x4lht"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"subslide"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"You’ll learn the syntax in a future lecture, but even now, it is clear that the code imports ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"HKaAcI4m6R"},{"type":"crossReference","label":"library","identifier":"term-library","children":[{"type":"text","value":"libraries","key":"lrSD15lhfK"}],"kind":"definitionTerm","template":"{name}","resolved":true,"html_id":"term-library","key":"cqTUH7OjzX"},{"type":"text","value":" for creating named tuples and making random choices, thanks to the design of Python being a high-level programming language.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"AcBTMgoBgs"}],"key":"OfsZDZJA9m"}],"key":"YHuU5JZe1b"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"To create a ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"R5BtkPZeRQ"},{"type":"inlineCode","value":"deck","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"RbOG2Luyde"},{"type":"text","value":" of cards, run the following cell.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"Ic2Uk2uuHy"}],"key":"EuPZqBDBO0"}],"key":"KWIWYfcCiP"},{"type":"block","kind":"notebook-code","data":{"editable":true,"slideshow":{"slide_type":"-"},"tags":["output-scroll"]},"children":[{"type":"code","lang":"python","executable":true,"value":"suits = (\"Diamond\", \"Club\", \"Heart\", \"Spade\")\nvalues = range(1, 14)\nCard = namedtuple(\"Card\", [\"value\", \"suit\"])\ndeck = [Card(value, suit) for value in values for suit in suits]\ndeck","visibility":"show","key":"tMCbfLA6HE"},{"type":"output","id":"-IpZsht_nHj98YhXshBVd","data":[],"visibility":"show","key":"CQICcEZlAx"}],"visibility":"show","key":"icW4Mdi8P1"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"The code above uses ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"cR9A8bW0Ms"},{"type":"crossReference","label":"composite data type","identifier":"term-composite data type","children":[{"type":"text","value":"composite data types","key":"parImsO3II"}],"kind":"definitionTerm","template":"{name}","resolved":true,"html_id":"term-composite-data-type","key":"qIUUsPDul2"},{"type":"text","value":" like tuples and lists, which will be formally introduced later in the course. They are handy for storing and manipulating collections of values.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"GVk5BHhXsn"}],"key":"eaG69dsXkt"}],"key":"EXgY5xD2xH"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Now, you can use the following program to play the game with your friends:","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"xypW4eJlpt"}],"key":"zelC6h8ox3"}],"key":"btHIRn5eD9"},{"type":"block","kind":"notebook-code","data":{"editable":true,"slideshow":{"slide_type":"-"}},"children":[{"type":"code","lang":"python","executable":true,"value":"choice(deck)","key":"sUBHqqrIIy"},{"type":"output","id":"-V5L3VHUj_BAFbDPzGj8B","data":[],"key":"pPt7UFntx0"}],"key":"KE8uJ4Tqpm"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"admonition","kind":"tip","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Tip","key":"aZuqL893XJ"}],"key":"brqe8LZzsq"},{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"To draw cards repeatedly, use ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"UkpvATqWfD"},{"type":"keyboard","children":[{"type":"text","value":"Ctrl-Enter","key":"gYNKiUjGdG"}],"key":"EiE9JbJWwd"},{"type":"text","value":" instead of ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"qeUPh28FFU"},{"type":"keyboard","children":[{"type":"text","value":"Shift-Enter","key":"ToJ0FqAQqs"}],"key":"KiQaimxn1S"},{"type":"text","value":" to run the code, so the same code cell stay selected after the execution. Note that function ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"g0sIR9HbZh"},{"type":"inlineCode","value":"choice","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"dxxgrhRh94"},{"type":"text","value":" is said to be an ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"YZt7p6F88c"},{"type":"link","url":"https://en.wikipedia.org/wiki/Pure_function","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"impure function","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"DWa0A7ZwYv"}],"urlSource":"https://en.wikipedia.org/wiki/Pure_function","data":{"page":"Pure_function","wiki":"https://en.wikipedia.org/","lang":"en"},"internal":false,"protocol":"wiki","key":"mqK69fgyAJ"},{"type":"text","value":" as it can return different values for repeated runs with the same input argument, namely ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"UW9FgTEMd3"},{"type":"inlineCode","value":"deck","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"gIvRfkd9dS"},{"type":"text","value":".","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"N5zC3SbHrJ"}],"key":"GKh1tT0szT"}],"key":"DZjzBAMxmj"}],"key":"Ok0bkdCEto"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"exercise","label":"ex:multiple-draw","identifier":"ex:multiple-draw","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Draw multiple cards","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"VjbAnK3tvp"}],"key":"afKgjYMcGw"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"Can you fix the code below so that it can return 5 cards randomly drawn with replacement from the deck of cards?","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"ygOqrGbPBU"}],"key":"y4SR7eyrx8"},{"type":"code","lang":"python","emphasizeLines":[2],"showLineNumbers":true,"value":"def draw_five_cards_randomly():\n    card1 = card2 = card3 = card4 = card5 = choice(deck)\n    return  card1, card2, card3, card4, card5","key":"qdLXWEjaNH"}],"enumerator":"2","html_id":"ex-multiple-draw","key":"Y2GkWc3uH8"}],"key":"JveHXq77tQ"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"nbgrader":{"cell_type":"code","checksum":"e88ddbfe661156ff81c8803fed46bfc0","grade":false,"grade_id":"multiple_draw","locked":false,"schema_version":3,"solution":true,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"def draw_five_cards_randomly():\n    # YOUR CODE HERE\n    raise NotImplementedError\n    return  card1, card2, card3, card4, card5","key":"j8AjSo5q3f"},{"type":"output","id":"ThmnE7UAuVEHyXmEhNQeD","data":[],"key":"xoz7buKUvj"}],"key":"SRXmo7ohlN"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"30f08021bea27962eee530954d4013b8","grade":true,"grade_id":"test-multiple_draw","locked":true,"points":1,"schema_version":3,"solution":false,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# tests\nimport random\n\nrandom.seed(1302)  # to make pseudo-random sequences reproducible\nassert (lambda cards: any(cards[i] != cards[4] for i in range(4)))(\n    draw_five_cards_randomly()\n)","key":"PJ25A1iviu"},{"type":"output","id":"SKMNfMcBXZ8fFJ7mQpksr","data":[],"key":"B64B1MFRHv"}],"key":"mvZCmKSYCm"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"6f62cf6c25def4aae8250d94d05f2c52","grade":true,"grade_id":"htest-multiple_draw","locked":true,"points":1,"schema_version":3,"solution":false,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# hidden tests","key":"YW7FozWZ5n"},{"type":"output","id":"kArs2K9Vj0ZJjYip1jexL","data":[],"key":"RXfIGzvlCG"}],"key":"Gi1eyIKpGD"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"admonition","kind":"caution","class":"dropdown","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Caution","key":"Q7O0GJvvW8"}],"key":"RmaagVBMSz"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"While one may pass the visible test with an answer like","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"MLUf8UpCQU"}],"key":"zkYCE9rU90"},{"type":"code","lang":"","value":"def draw_five_cards_randomly():\n    card1 = card2 = card3 = card4 = card5 = choice(deck)\n    card1 = 0\n    return  card1, card2, card3, card4, card5","position":{"start":{"line":6,"column":1},"end":{"line":11,"column":1}},"key":"nzsN9dvV7y"},{"type":"paragraph","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"text","value":"Who knows whether the hidden test would catch that ","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"ThxAfQLl8w"},{"type":"inlineCode","value":"card1","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"CpRsbA2hHH"},{"type":"text","value":" is not even a card in the ","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"wfTN4BQzdE"},{"type":"inlineCode","value":"deck","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"kpZ5w1RMOz"},{"type":"text","value":"? The hidden test can also be modified since it is not hard coded in the notebook.","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"DFZjvQDNzE"}],"key":"jcMlAIG8cX"}],"key":"ZogJFrOT4d"}],"key":"uMVidIBJLK"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"heading","depth":3,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Virtual Player","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"GG9nW2FjwR"}],"identifier":"virtual-player","label":"Virtual Player","html_id":"virtual-player","implicit":true,"key":"lRL9kjEUv8"}],"key":"puvsmujkFL"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Given you have randomly drawn a card,","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"fp1bZ4ZqY6"}],"key":"g5eNVcPTnu"},{"type":"list","ordered":true,"start":1,"spread":false,"position":{"start":{"line":3,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"run the following code cell, and","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"EBBepql3oj"}],"key":"NB5AJsEpjB"},{"type":"listItem","spread":true,"position":{"start":{"line":4,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"text","value":"answer the 6 questions raised by the player honestly by entering","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"E6KgMlpkTc"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":5,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"inlineCode","value":"1","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"nYKXktisD5"},{"type":"text","value":" for yes and","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"TsD4DqR9ZN"}],"key":"PrRPPRsg0l"},{"type":"listItem","spread":true,"position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"inlineCode","value":"0","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"AspmHWoIO3"},{"type":"text","value":" for no.","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"k5xiYDDu5L"}],"key":"EoNb5qjhFI"}],"key":"deqG6xlbEw"}],"key":"hdJlNYC7Rb"}],"key":"X6CtlN2w1w"}],"key":"jb9nQTKOnq"},{"type":"block","kind":"notebook-code","data":{"slideshow":{"slide_type":"-"},"tags":[]},"children":[{"type":"code","lang":"python","executable":true,"value":"def is_yes(question):\n    \"\"\"Get an answer to a yes/no question.\"\"\"\n    return \"1\" == input(question + \" 1:yes [0:no] \")\n\n\nsuit_idx = number = 0\nif is_yes(\"Is the suite either heart or spade?\"):\n    suit_idx += 2\nif is_yes(\"Is the suite either club or spade?\"):\n    suit_idx += 1\nfor i in range(3, -1, -1):\n    number += 2**i * is_yes(f\"Is the number {number+2**i} or above?\")\nprint(f\"The card is {suits[suit_idx]} {number}\")","visibility":"show","key":"x8j9q6PMQM"},{"type":"output","id":"gvQZ5cjHVbzqi191HT40a","data":[],"visibility":"remove","key":"Oj1Wfw59it"}],"visibility":"show","key":"HDxIawCiBJ"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"The code above provides an overview of various programming syntaxes to be covered in the course. Although you don’t need to be familiar with them now, it’s good to have a basic understanding:","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"TZn4X2VkE2"}],"key":"fsjspzG8iN"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":3,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"The program first defines a function called ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"Yk7zw0hlwU"},{"type":"inlineCode","value":"is_yes","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"cgbWXNt9RZ"},{"type":"text","value":" that checks whether the answer to a given question is yes.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"ZqyypsMesQ"}],"key":"ivHKlHaqJd"},{"type":"listItem","spread":true,"position":{"start":{"line":4,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"To compute the guess, the program modifies the values of the variables ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"rR46m4UVrC"},{"type":"inlineCode","value":"suit_idx","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"Rpr5QYIWxi"},{"type":"text","value":" and ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"PCQltJNBmS"},{"type":"inlineCode","value":"number","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"inNYuXr3Fy"},{"type":"text","value":" using","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"ylFrnyM5bj"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":5,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"crossReference","label":"conditional","identifier":"term-conditional","kind":"definitionTerm","children":[{"type":"text","value":"conditional","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"I7Nsdc6UxT"}],"template":"{name}","resolved":true,"html_id":"term-conditional","key":"wRvonJKPQj"},{"type":"text","value":" ","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"rBCKXB9afL"},{"type":"inlineCode","value":"if","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"MpNtFGXRm5"},{"type":"text","value":" statements and","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"BSKMwtHZYD"}],"key":"cKM7b666LP"},{"type":"listItem","spread":true,"position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"text","value":"a ","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"dcGTkKfsnI"},{"type":"inlineCode","value":"for","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"AcLlDKRJSB"},{"type":"text","value":" ","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"GCkdBUjagV"},{"type":"crossReference","label":"iteration","identifier":"term-iteration","children":[{"type":"text","value":"loop","key":"fac9BtHzWu"}],"kind":"definitionTerm","template":"{name}","resolved":true,"html_id":"term-iteration","key":"nU8ulc92tl"},{"type":"text","value":", along with","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"oUTTTBz1wv"}],"key":"oUFfw6GNfZ"},{"type":"listItem","spread":true,"position":{"start":{"line":7,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"different operations such as","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"URcmGdPlVT"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":8,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"children":[{"type":"text","value":"chained assignment ","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"ViULzaclHe"},{"type":"inlineCode","value":"=","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"XtsNEx3Kkc"},{"type":"text","value":",","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"GTlBH4TCh2"}],"key":"pt0Gqjwczc"},{"type":"listItem","spread":true,"position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"children":[{"type":"text","value":"augmented assignment ","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"rZrvJRHy6I"},{"type":"inlineCode","value":"+=","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"MMeUD4afE0"},{"type":"text","value":",","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"SpCb5uq6t3"}],"key":"JKN5UpWxdp"},{"type":"listItem","spread":true,"position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"children":[{"type":"text","value":"equality comparison ","position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"key":"P27bGwoMs8"},{"type":"inlineCode","value":"==","position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"key":"OHjvIbPmyv"},{"type":"text","value":", and","position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"key":"MCchPLzwQE"}],"key":"j3QrYmAb2T"},{"type":"listItem","spread":true,"position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"exponentiation ","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"x5rp3Xk644"},{"type":"inlineCode","value":"**","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"HE8xQqZ7F0"},{"type":"text","value":".","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"zTAFnV3RSF"}],"key":"Bwy6bEibg7"}],"key":"NyEefdsujQ"}],"key":"rKHg5nCwSh"}],"key":"IkGluFOCrk"}],"key":"c7PDZZHGaI"}],"key":"fvEe4pbDJp"}],"key":"Ls6NFeheTu"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"exercise","label":"ex:resolution-capacity","identifier":"ex:resolution-capacity","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Resolution of uncertainty","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"ds5ymkf60K"}],"key":"obRi8bUjTn"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"Hope you are convinced that the virtual player has a winning strategy. Indeed, the answers to 6 questions not only resolve the uncertainty of a random draw from 6 cards, but they can also resolve a random draw from over 52 cards. Fix the following function number_of_cards so that it returns the maximum number of cards from which a random draw can be resolved by the answers to a number of questions specified by an integer assigned to the variable ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"ExTRA4R9HM"},{"type":"inlineCode","value":"number_of_questions","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"dLNaysVHJx"},{"type":"text","value":".","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"D5rn7rk0jc"}],"key":"aktCPf5C9h"},{"type":"code","lang":"python","emphasizeLines":[2],"showLineNumbers":true,"value":"def number_of_cards(number_of_questions):\n    ans = number_of_questions\n    return ans","key":"jQ6U8wZGbv"},{"type":"paragraph","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"children":[{"type":"text","value":"You may assume one can add new values/suits so that a deck may have an arbitrarily number of distinct cards.","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"jzJl5m5bbz"}],"key":"pg2FnDO9kQ"}],"enumerator":"3","html_id":"ex-resolution-capacity","key":"cIRk1TOQlU"}],"key":"JjVYr7Ad9q"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"nbgrader":{"cell_type":"code","checksum":"d43acb83c79cb8d388895f01cff95181","grade":false,"grade_id":"resolution_capacity","locked":false,"schema_version":3,"solution":true,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"def number_of_cards(number_of_questions):\n    # YOUR CODE HERE\n    raise NotImplementedError\n    return ans","key":"pJb1KqS31r"},{"type":"output","id":"lDMamunsHx67V3lYzDClt","data":[],"key":"gCnZTr11y8"}],"key":"jgzNIQdvNk"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"72dee2c86ec91b145b7b0f19efc1442f","grade":true,"grade_id":"test-resolution_capacity","locked":true,"points":1,"schema_version":3,"solution":false,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# tests\nassert number_of_cards(number_of_questions=6) > len(deck) ","key":"RugFDwZBnS"},{"type":"output","id":"H2nbQzUw5MdZMbuwEGcaP","data":[],"key":"IzFmBHuwUA"}],"key":"pK4n3I6QNp"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"6c956b4ffb271f2127d922a07c49ee3e","grade":true,"grade_id":"htest-resolution_capacity","locked":true,"points":1,"schema_version":3,"solution":false,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# hidden tests","key":"XB8CYGuW5h"},{"type":"output","id":"8YxHPBDwMlRahfum5EY-y","data":[],"key":"elHLGuN6of"}],"key":"KZFmXR4QP5"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"admonition","kind":"caution","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Caution","key":"lEtDSpimUU"}],"key":"lnM0c4Pinx"},{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"The value of ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"ZoLtADyhEz"},{"type":"inlineCode","value":"number_of_questions","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"WwFfJSub39"},{"type":"text","value":" can be very large in the hidden test.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"znN3zljNhL"}],"key":"baRMNHFc0L"}],"key":"qp4TvTWIt8"}],"key":"XMxOwmtwPN"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"heading","depth":2,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Binary Number System","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"D12C1ko3nw"}],"identifier":"binary-number-system","label":"Binary Number System","html_id":"binary-number-system","implicit":true,"key":"oLnWEU6Mhv"}],"key":"yE6CAavv9P"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"slide"}},"children":[{"type":"heading","depth":3,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Representing non-negative integers","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"sSZpMSus5n"}],"identifier":"representing-non-negative-integers","label":"Representing non-negative integers","html_id":"representing-non-negative-integers","implicit":true,"key":"K7Nb4S3yl2"}],"key":"DM4dfPqonA"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"The following table gives the binary representions of unsigned decimal integers from 0 to 7.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"nOcw1TlEA7"}],"key":"tJxlkPTG6x"}],"key":"jZc6l8TEMB"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"container","kind":"table","children":[{"type":"caption","children":[{"type":"paragraph","children":[{"type":"captionNumber","kind":"table","label":"tab:pos-int","identifier":"tab:pos-int","html_id":"tab-pos-int","enumerator":"2","children":[{"type":"text","value":"Table ","key":"vfURGWDoip"},{"type":"text","value":"2","key":"Zq5I2Fqji8"},{"type":"text","value":":","key":"L54XrWZS3o"}],"template":"Table %s:","key":"nXSdbGebMk"},{"type":"text","value":"Encoding positive integers","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"FcG3Tz4fXv"}],"key":"foG5VzWVvp"}],"key":"x7hloQRt3A"},{"type":"table","children":[{"type":"tableRow","children":[{"type":"tableCell","header":true,"children":[{"type":"text","value":"Binary","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"s4z1C4iajH"}],"key":"DU9i3cZDpN"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"Decimal","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"d2ZFUu5rpE"}],"key":"s4gNz8Tydy"}],"key":"gToQ1Dptbd"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"000","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"FBTirpNo3g"}],"key":"d3kaNRzQgb"},{"type":"tableCell","children":[{"type":"text","value":"0","position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"key":"ofhyv3wOLW"}],"key":"Ge92waMpvn"}],"key":"pLFngW6Myd"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"001","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"oNLZ2R3KeS"}],"key":"lXnv2uJtED"},{"type":"tableCell","children":[{"type":"text","value":"1","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"wQWACeXx9r"}],"key":"cCHCNG5G8i"}],"key":"sLWvCj95gQ"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"010","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"FWUNXQLDjQ"}],"key":"URlAX5EE3r"},{"type":"tableCell","children":[{"type":"text","value":"2","position":{"start":{"line":16,"column":1},"end":{"line":16,"column":1}},"key":"f3EWhPHlfh"}],"key":"GSkOhqr0V4"}],"key":"gtz09dx1AG"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"011","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"sxLfL1rGHs"}],"key":"JBPQZTBmCH"},{"type":"tableCell","children":[{"type":"text","value":"3","position":{"start":{"line":19,"column":1},"end":{"line":19,"column":1}},"key":"kUdq3ZFyV3"}],"key":"cYBAQgFKyF"}],"key":"b7RXv5H5mf"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"i0KwHI7AnT"}],"key":"VnUwrefJhh"},{"type":"text","value":"00","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"LDnoQOwipg"}],"key":"PT5IzaDwFl"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":22,"column":1},"end":{"line":22,"column":1}},"children":[{"type":"text","value":"4","position":{"start":{"line":22,"column":1},"end":{"line":22,"column":1}},"key":"S1LJ0RkYZ4"}],"key":"V3LqmaPRKG"}],"key":"a51oyT1eAd"}],"key":"W5ND8hSg7J"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"key":"msDvnnkW27"}],"key":"fRY2yEN9wV"},{"type":"text","value":"01","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"key":"j9pYjqljpN"}],"key":"QPT5UjI0QW"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":25,"column":1},"end":{"line":25,"column":1}},"children":[{"type":"text","value":"5","position":{"start":{"line":25,"column":1},"end":{"line":25,"column":1}},"key":"aocOQWurzh"}],"key":"dvTXRCQVkY"}],"key":"VwEFjiaVfM"}],"key":"DjLOboGEoI"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"key":"USCSSJgWut"}],"key":"X9hVCWAr2e"},{"type":"text","value":"10","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"key":"kaJY8R8K8B"}],"key":"KhKVk2vBA5"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":28,"column":1},"end":{"line":28,"column":1}},"children":[{"type":"text","value":"6","position":{"start":{"line":28,"column":1},"end":{"line":28,"column":1}},"key":"qROugd3GbX"}],"key":"HQ5ll77ygT"}],"key":"s1MDYYJF96"}],"key":"FRn0K0l8HF"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"Ual0BMYcBC"}],"key":"BNzysmW7kh"},{"type":"text","value":"11","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"m83aj75WXY"}],"key":"fQEjG16o6O"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":31,"column":1},"end":{"line":31,"column":1}},"children":[{"type":"text","value":"7","position":{"start":{"line":31,"column":1},"end":{"line":31,"column":1}},"key":"V46D0zkZ1P"}],"key":"veoiJKIY3j"}],"key":"UZXRLr2Iqs"}],"key":"sqGXktSLxn"}],"key":"QM3j7tnprn"}],"label":"tab:pos-int","identifier":"tab:pos-int","enumerator":"2","html_id":"tab-pos-int","key":"z7QyueIyoT"}],"key":"OQ9SQWhOYS"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Observe that the binary representations of 4, 5, 6, and 7 all have ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"v2wqw5IITB"},{"type":"strong","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"X4Z8kojrV6"}],"key":"nmRutXQfRX"},{"type":"text","value":" in the leftmost (most significant) bit. Consider that bit as the answer to the following ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"AVCKDAiMGx"},{"type":"strong","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"yes/no","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"BSjRKDQiKT"}],"key":"BxwkTeNYBV"},{"type":"text","value":" question when converting an integer ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"GzLxnDuLtB"},{"type":"inlineCode","value":"n","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"x4f6oAzTLa"},{"type":"text","value":" to binary:","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"P4mg8ccRVY"}],"key":"eVVeJT4ANG"},{"type":"blockquote","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"Is the integer 4 or above, i.e., ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"EysuPh5EuA"},{"type":"inlineMath","value":"n\\geq 4","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>n</mi><mo>≥</mo><mn>4</mn></mrow><annotation encoding=\"application/x-tex\">n\\geq 4</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7719em;vertical-align:-0.136em;\"></span><span class=\"mord mathnormal\">n</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">≥</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6444em;\"></span><span class=\"mord\">4</span></span></span></span>","key":"cgdRT8dqP7"},{"type":"text","value":"?","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"a3MNqyvAlr"}],"key":"JkLNCp4CGn"}],"key":"aAtM8jd76Y"}],"key":"Aa7NRn0x82"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Now, to convert the entire binary sequence to decimal, we can think of the conversion as a guessing game where","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"d6wXXfBKLd"}],"key":"KhmacnZx0D"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":2,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"the binary sequence is a sequence of ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"Xu9V7bSWOl"},{"type":"strong","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"yes (1)","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"I9liXjjRtW"}],"key":"rTR8LZN5uL"},{"type":"text","value":" or ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"XQfgBsVTY5"},{"type":"strong","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"no (0)","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"YKzY9JGJ7V"}],"key":"HmYMNbGZI5"},{"type":"text","value":" answers to certain ","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"IIWZjEtzPR"},{"type":"strong","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"yes/no","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"e9tRNsmhph"}],"key":"BSDfCIOEpJ"},{"type":"text","value":" questions, and","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"duOzZBXmzo"}],"key":"sHyBQRs75Q"},{"type":"listItem","spread":true,"position":{"start":{"line":3,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"the informed guess is the integer represented by the binary sequence.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"F9xTLG8ql7"}],"key":"uuF6FZEgGU"}],"key":"vz45igFmVT"},{"type":"image","url":"/~ccha23/cs1302_24a/build/dt.dio-da8d41a3d9775b3c4ed1e6b237808e61.svg","alt":"Decoding tree","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"eVUUA5oOMt","urlSource":"images/dt.dio.svg"}],"key":"WNof8nbWgP"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"The following code attempts to convert integers between 0 and 7 to their binary strings.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"zt5YN45GZS"}],"key":"uNshGPJgKE"}],"key":"Dmrj8eddu0"},{"type":"block","kind":"notebook-code","data":{},"children":[{"type":"code","lang":"python","executable":true,"value":"def decimal_to_binary(n):\n    def get_bit(cond):\n        return \"1\" if cond else \"0\"\n    return get_bit(eval(Q1)) + get_bit(eval(Q2)) + get_bit(eval(Q3))\n\n# Define the questions\nQ1, Q2, Q3 = \"n >= 4\", \"n >= 2\", \"n >= 1\"\n\n# Print the conversions decimal (binary)\nprint(*[f\"{i} ({decimal_to_binary(i)})\" for i in range(8)], sep=\"\\n\")","key":"LpbjNbEn3l"},{"type":"output","id":"VqIG764F_W9QjPGIvxDJQ","data":[],"key":"Kev1jV99Uh"}],"key":"napIXoYPUM"},{"type":"block","kind":"notebook-content","data":{},"children":[{"type":"exercise","label":"ex:d2b","identifier":"ex:d2b","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"question to ask","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"bFI2P9SOvZ"}],"key":"si6MMEQEZS"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"Although the conversions for 0, 1, 3, and 7 are correct, the conversions for 2, 4, 5, and 6 are incorrect. Fix the issue by assigning the correct strings to Q2 and Q3. Similar to Q1, each of the strings should be a valid Python expression that can be evaluated with ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"cSzL8xwn37"},{"type":"inlineCode","value":"n","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"aIbpxFNUEY"},{"type":"text","value":" being the integer to convert to a binary string.","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"TyZ6rgomb1"}],"key":"RGebFR8ZM7"},{"type":"admonition","kind":"hint","class":"dropdown","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Hint","key":"wo0zEeX3AF"}],"key":"wnPxAe99Ys"},{"type":"paragraph","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"children":[{"type":"text","value":"Consider the modulo operator ","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"TjUY7ne7SA"},{"type":"inlineCode","value":"%","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"OefyUon4De"},{"type":"text","value":".","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"DsdvYkVcTa"}],"key":"U13I5odiie"},{"type":"admonition","kind":"seealso","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"See Also","key":"lKMfRlpEJ5"}],"key":"EpEYVAXQQM"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":12,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"children":[{"type":"link","url":"https://www.mathsisfun.com/binary-number-system.html","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"children":[{"type":"text","value":"Binary Number System","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"pUfQiEHr2a"}],"urlSource":"https://www.mathsisfun.com/binary-number-system.html","key":"B7pY9ymbSa"},{"type":"text","value":" and","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"JCVU3P4k8b"}],"key":"mmdSZL5kVJ"},{"type":"listItem","spread":true,"position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"link","url":"https://www.purplemath.com/modules/numbbase.htm","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"children":[{"type":"text","value":"Binary Number Conversions","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"zGPmVAueLG"}],"urlSource":"https://www.purplemath.com/modules/numbbase.htm","key":"upR2sRv5yy"},{"type":"text","value":".","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"Qdf8ObG2IN"}],"key":"Bjzex1myws"}],"key":"SD29ha4H1I"}],"key":"KhhH7Rdnj5"}],"key":"AljRVKIunh"}],"enumerator":"4","html_id":"ex-d2b","key":"Uqkm2rk6V2"}],"key":"HPquLOJ8XK"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"nbgrader":{"cell_type":"code","checksum":"a08ff85222d04b5d50e31a57e47a78be","grade":false,"grade_id":"d2b","locked":false,"schema_version":3,"solution":true,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# Assign strings to Q2 and Q3\n# YOUR CODE HERE\nraise NotImplementedError\nQ2, Q3","key":"ykNKQexyXj"},{"type":"output","id":"Fvi7daLVsGxZ4RfEHQSSo","data":[],"key":"iLCh9ho2hQ"}],"key":"oP7tKBIMpa"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"6bcf1c5abe0c63c517d24d7d7dcfc4fe","grade":true,"grade_id":"test-d2b","locked":true,"points":1,"schema_version":3,"solution":false,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# test\nassert decimal_to_binary(2) == '010'\nassert decimal_to_binary(4) == '100'\nassert decimal_to_binary(5) == '101'\nassert decimal_to_binary(6) == '110' ","key":"eqQyjSch7V"},{"type":"output","id":"HP6acSfZQLkZpKjM-Ui5u","data":[],"key":"H8LcBYdi1u"}],"key":"CUG9s4NEo8"},{"type":"block","kind":"notebook-code","data":{"deletable":false,"editable":false,"nbgrader":{"cell_type":"code","checksum":"d0981384ae49e04fbcb715287361f6c5","grade":true,"grade_id":"htest-d2b","locked":true,"points":1,"schema_version":3,"solution":false,"task":false}},"children":[{"type":"code","lang":"python","executable":true,"value":"# hidden tests","key":"vRNmcJiKJE"},{"type":"output","id":"J1VwYasnCqiC9UASvgHJg","data":[],"key":"nLPJx4JxPV"}],"key":"vnKDjmlnDD"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"slide"}},"children":[{"type":"heading","depth":3,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Representing negative numbers","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"TpCxe4nEye"}],"identifier":"representing-negative-numbers","label":"Representing negative numbers","html_id":"representing-negative-numbers","implicit":true,"key":"nuTOzblsoU"}],"key":"Un7OXEMV4c"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"The following also uses 3 bits to represent 8 integers but half of them are negative.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"pv0Rh3B5pV"}],"key":"AZimYHKh77"}],"key":"Q3iP2LtgDo"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"-"}},"children":[{"type":"container","kind":"table","children":[{"type":"caption","children":[{"type":"paragraph","children":[{"type":"captionNumber","kind":"table","label":"tab:neg-int","identifier":"tab:neg-int","html_id":"tab-neg-int","enumerator":"3","children":[{"type":"text","value":"Table ","key":"VTQRslSmpY"},{"type":"text","value":"3","key":"iZQiF4rNhV"},{"type":"text","value":":","key":"h6bCqvve5U"}],"template":"Table %s:","key":"yK4aRxqJbt"},{"type":"text","value":"Encoding positive integers","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"OMYrYBjByj"}],"key":"RQaOhRfXWX"}],"key":"t2pAFkmtww"},{"type":"table","children":[{"type":"tableRow","children":[{"type":"tableCell","header":true,"children":[{"type":"text","value":"Binary","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"gRhkRPVqAr"}],"key":"Lk1UXrUKcD"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"Decimal","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"goxt41DueQ"}],"key":"X3kefqNzUF"}],"key":"YkLFCShXaW"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"000","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"MVpDzEBJSG"}],"key":"ZETkYw5ozd"},{"type":"tableCell","children":[{"type":"text","value":"0","position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"key":"cVkOCyUwFm"}],"key":"R3TjK8WNm9"}],"key":"ZLF4JcLpbE"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"001","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"aPfmwWnXi6"}],"key":"O8lxUxBYaK"},{"type":"tableCell","children":[{"type":"text","value":"1","position":{"start":{"line":13,"column":1},"end":{"line":13,"column":1}},"key":"OaaMdxyUfO"}],"key":"aPDF1Y64lU"}],"key":"u8HFYNXOd4"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"010","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"fQ3R6kgmy4"}],"key":"rhC0JpLWih"},{"type":"tableCell","children":[{"type":"text","value":"2","position":{"start":{"line":16,"column":1},"end":{"line":16,"column":1}},"key":"wR1y54CMpT"}],"key":"VqbE2zRkOj"}],"key":"rB6uK43dh6"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"011","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"F5npNGICcH"}],"key":"ZlafbDe6H2"},{"type":"tableCell","children":[{"type":"text","value":"3","position":{"start":{"line":19,"column":1},"end":{"line":19,"column":1}},"key":"e0iuqcsUqo"}],"key":"qyapCrfFHj"}],"key":"pMPzTeQrvX"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"fnDgScdmNe"}],"key":"MMtC9icumM"},{"type":"text","value":"00","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"rwK2kHJpR4"}],"key":"Pjz8VVIht6"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":22,"column":1},"end":{"line":22,"column":1}},"children":[{"type":"text","value":"-4","position":{"start":{"line":22,"column":1},"end":{"line":22,"column":1}},"key":"lcyUHduGFK"}],"key":"wbzR6hy9Qn"}],"key":"u0GDxUGAeP"}],"key":"oRR12P0PKU"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"key":"jhkFaH5Uxa"}],"key":"TF44EiZCvI"},{"type":"text","value":"01","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"key":"bpaYNHtWNF"}],"key":"oa0diWL8Ha"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":25,"column":1},"end":{"line":25,"column":1}},"children":[{"type":"text","value":"-3","position":{"start":{"line":25,"column":1},"end":{"line":25,"column":1}},"key":"cOPLauOag8"}],"key":"hChHjnPKU7"}],"key":"ygGEP6VS16"}],"key":"xVrPYHZxdE"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"key":"UUvumRCb19"}],"key":"df5wOxkNhF"},{"type":"text","value":"10","position":{"start":{"line":27,"column":1},"end":{"line":27,"column":1}},"key":"DvnLDo1KX3"}],"key":"wYdawlp7VK"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":28,"column":1},"end":{"line":28,"column":1}},"children":[{"type":"text","value":"-2","position":{"start":{"line":28,"column":1},"end":{"line":28,"column":1}},"key":"uJdW9MOUvG"}],"key":"lzIgGhl0oI"}],"key":"G8O0bwlXrs"}],"key":"I2DSqzfAyx"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"children":[{"type":"text","value":"1","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"FNbocRp4P2"}],"key":"dIADq2mnie"},{"type":"text","value":"11","position":{"start":{"line":30,"column":1},"end":{"line":30,"column":1}},"key":"QnmFmW4E48"}],"key":"WnpMYKNUgz"},{"type":"tableCell","children":[{"type":"strong","position":{"start":{"line":31,"column":1},"end":{"line":31,"column":1}},"children":[{"type":"text","value":"-1","position":{"start":{"line":31,"column":1},"end":{"line":31,"column":1}},"key":"doaA5Sqzfj"}],"key":"uBaXq6trel"}],"key":"WQsmvFeL2u"}],"key":"aAAjWwsSy9"}],"key":"SS2ACJH4hh"}],"label":"tab:neg-int","identifier":"tab:neg-int","enumerator":"3","html_id":"tab-neg-int","key":"FmGH78QPCY"}],"key":"jlCbhOt1pO"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"admonition","kind":"note","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Note","key":"NE7c7oH85W"}],"key":"UedI8FK7Ur"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":3,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"The numbers 0, 1, 2, and 3 have the same binary representations as before, but","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"AgK1TZpz8Z"}],"key":"dGEJge75dq"},{"type":"listItem","spread":true,"position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"the binary representations for 4, 5, 6, and 7 are now used for -4, -3, -2, and -1.","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"xgqnyRxLy4"}],"key":"KaQX4uB17S"}],"key":"Ms5C0JbLF3"}],"key":"BlhaAcrGtp"}],"key":"X2fFf2oLF4"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"subslide"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"strong","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"What is the benefit of the above representation?","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"yC7NSZpgJV"}],"key":"bYtBTc8nqE"}],"key":"xFhyBoYUu2"}],"key":"I8pJkV11eH"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"To subtract a positive binary number ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"VQHd5dqci9"},{"type":"inlineMath","value":"x","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>x</mi></mrow><annotation encoding=\"application/x-tex\">x</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.4306em;\"></span><span class=\"mord mathnormal\">x</span></span></span></span>","key":"h4q8VtwLj4"},{"type":"text","value":" from another positive binary number ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"rahIWd7BAo"},{"type":"inlineMath","value":"y","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>y</mi></mrow><annotation encoding=\"application/x-tex\">y</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.625em;vertical-align:-0.1944em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">y</span></span></span></span>","key":"YXfhrGbZ1G"},{"type":"text","value":", i.e.,","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"miCdPTAO9X"}],"key":"BZ6wd2j7PQ"},{"type":"math","value":"x - y,","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"html":"<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>x</mi><mo>−</mo><mi>y</mi><mo separator=\"true\">,</mo></mrow><annotation encoding=\"application/x-tex\">x - y,</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"></span><span class=\"mord mathnormal\">x</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">−</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.625em;vertical-align:-0.1944em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">y</span><span class=\"mpunct\">,</span></span></span></span></span>","enumerator":"1","key":"oSjaMIa6WZ"},{"type":"paragraph","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"it seems we can instead perform the binary addition","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"PgXU21mtif"}],"key":"aAbGE3Tcd4"},{"type":"math","value":"x + (-y)","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"html":"<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>x</mi><mo>+</mo><mo stretchy=\"false\">(</mo><mo>−</mo><mi>y</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">x + (-y)</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"></span><span class=\"mord mathnormal\">x</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">+</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:1em;vertical-align:-0.25em;\"></span><span class=\"mopen\">(</span><span class=\"mord\">−</span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">y</span><span class=\"mclose\">)</span></span></span></span></span>","enumerator":"2","key":"iX2L23QIco"},{"type":"paragraph","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"children":[{"type":"text","value":"of a positive binary number ","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"J050gl4eSQ"},{"type":"inlineMath","value":"x","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>x</mi></mrow><annotation encoding=\"application/x-tex\">x</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.4306em;\"></span><span class=\"mord mathnormal\">x</span></span></span></span>","key":"FPBQ2H7gH3"},{"type":"text","value":" and a negative binary number ","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"RkMnRKWveS"},{"type":"inlineMath","value":"-y","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mo>−</mo><mi>y</mi></mrow><annotation encoding=\"application/x-tex\">-y</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7778em;vertical-align:-0.1944em;\"></span><span class=\"mord\">−</span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em;\">y</span></span></span></span>","key":"ZxN9iV9CHl"},{"type":"text","value":".","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"RzkRDoL0Bj"}],"key":"mvKi9LrSZf"}],"key":"Cr9VCWJYh9"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"subslide"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"For example,","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"yTJ0eZzama"}],"key":"WyuIVnLyS5"},{"type":"math","value":"\\overbrace{011_2}^{3} + \\overbrace{100_2}^{-4} = \\underbrace{111_2}_{-1}","position":{"start":{"line":3,"column":1},"end":{"line":5,"column":1}},"html":"<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mover><mover><mrow><mn>01</mn><msub><mn>1</mn><mn>2</mn></msub></mrow><mo stretchy=\"true\">⏞</mo></mover><mn>3</mn></mover><mo>+</mo><mover><mover><mrow><mn>10</mn><msub><mn>0</mn><mn>2</mn></msub></mrow><mo stretchy=\"true\">⏞</mo></mover><mrow><mo>−</mo><mn>4</mn></mrow></mover><mo>=</mo><munder><munder><mrow><mn>11</mn><msub><mn>1</mn><mn>2</mn></msub></mrow><mo stretchy=\"true\">⏟</mo></munder><mrow><mo>−</mo><mn>1</mn></mrow></munder></mrow><annotation encoding=\"application/x-tex\">\\overbrace{011_2}^{3} + \\overbrace{100_2}^{-4} = \\underbrace{111_2}_{-1}</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:2.0935em;vertical-align:-0.15em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.9435em;\"><span style=\"top:-3.2924em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.2924em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">01</span><span class=\"mord\"><span class=\"mord\">1</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span></span></span><span class=\"svg-align\" style=\"top:-3.7444em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"stretchy\" style=\"height:0.548em;min-width:1.6em;\"><span class=\"brace-left\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class=\"brace-center\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class=\"brace-right\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span style=\"top:-4.7849em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">3</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">+</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:2.1519em;vertical-align:-0.15em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.0019em;\"><span style=\"top:-3.2924em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.2924em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">10</span><span class=\"mord\"><span class=\"mord\">0</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span></span></span><span class=\"svg-align\" style=\"top:-3.7444em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"stretchy\" style=\"height:0.548em;min-width:1.6em;\"><span class=\"brace-left\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class=\"brace-center\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class=\"brace-right\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span style=\"top:-4.8432em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">−</span><span class=\"mord mtight\">4</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:2.1519em;vertical-align:-1.5074em;\"></span><span class=\"mord munder\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.6444em;\"><span style=\"top:-1.5509em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">−</span><span class=\"mord mtight\">1</span></span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord munder\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.6444em;\"><span class=\"svg-align\" style=\"top:-2.202em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"stretchy\" style=\"height:0.548em;min-width:1.6em;\"><span class=\"brace-left\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class=\"brace-center\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class=\"brace-right\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">11</span><span class=\"mord\"><span class=\"mord\">1</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.798em;\"><span></span></span></span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.5074em;\"><span></span></span></span></span></span></span></span></span></span>","enumerator":"3","key":"aUjZcskgPo"}],"key":"aAp1tD5AKN"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"subslide"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"It seem to work as well if there are bits carried forward, e.g., ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"axDlVxE4kn"},{"type":"inlineMath","value":"1 + (- 3)","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mn>1</mn><mo>+</mo><mo stretchy=\"false\">(</mo><mo>−</mo><mn>3</mn><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">1 + (- 3)</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7278em;vertical-align:-0.0833em;\"></span><span class=\"mord\">1</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">+</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:1em;vertical-align:-0.25em;\"></span><span class=\"mopen\">(</span><span class=\"mord\">−</span><span class=\"mord\">3</span><span class=\"mclose\">)</span></span></span></span>","key":"oy3m5syWgw"},{"type":"text","value":" in binary is","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"VQ3D2dVwtD"}],"key":"hfu2QOHcFM"},{"type":"math","value":"\\begin{array}{rrrr}\n & 0 & \\overset{\\color{blue} 1}0 & 1 \\\\\n+ & 1 & 0 & 1 \\\\\\hline\n& 1 & 1 &  0 \n\\end{array}","position":{"start":{"line":3,"column":1},"end":{"line":9,"column":1}},"html":"<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mtable rowspacing=\"0.16em\" columnalign=\"right right right right\" columnspacing=\"1em\" rowlines=\"none solid\"><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>0</mn></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mi><mover><mo><mn>0</mn></mo><mstyle mathcolor=\"blue\"><mn>1</mn></mstyle></mover></mi></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>1</mn></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mo lspace=\"0em\" rspace=\"0em\">+</mo></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>1</mn></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>0</mn></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>1</mn></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>1</mn></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>1</mn></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mn>0</mn></mstyle></mtd></mtr></mtable><annotation encoding=\"application/x-tex\">\\begin{array}{rrrr}\n &amp; 0 &amp; \\overset{\\color{blue} 1}0 &amp; 1 \\\\\n+ &amp; 1 &amp; 0 &amp; 1 \\\\\\hline\n&amp; 1 &amp; 1 &amp;  0 \n\\end{array}</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:4.1555em;vertical-align:-1.8278em;\"></span><span class=\"mord\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.3278em;\"><span style=\"top:-4.3278em;\"><span class=\"pstrut\" style=\"height:4.3278em;\"></span><span class=\"mtable\"><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"col-align-r\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.3278em;\"><span style=\"top:-4.3278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"></span></span><span style=\"top:-3.1278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">+</span></span></span><span style=\"top:-1.9278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.8278em;\"><span></span></span></span></span></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"col-align-r\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.3278em;\"><span style=\"top:-4.3278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">0</span></span></span><span style=\"top:-3.1278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">1</span></span></span><span style=\"top:-1.9278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">1</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.8278em;\"><span></span></span></span></span></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"col-align-r\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.3278em;\"><span style=\"top:-4.3278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\"><span class=\"mop op-limits\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.3955em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span><span class=\"mop\">0</span></span></span><span style=\"top:-3.8444em;margin-left:0em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\" style=\"color:blue;\">1</span></span></span></span></span></span></span></span></span></span></span><span style=\"top:-3.1278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">0</span></span></span><span style=\"top:-1.9278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">1</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.8278em;\"><span></span></span></span></span></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span><span class=\"col-align-r\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.3278em;\"><span style=\"top:-4.3278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">1</span></span></span><span style=\"top:-3.1278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">1</span></span></span><span style=\"top:-1.9278em;\"><span class=\"pstrut\" style=\"height:3.3955em;\"></span><span class=\"mord\"><span class=\"mord\">0</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.8278em;\"><span></span></span></span></span></span><span class=\"arraycolsep\" style=\"width:0.5em;\"></span></span></span><span style=\"top:-3.7em;\"><span class=\"pstrut\" style=\"height:4.3278em;\"></span><span class=\"hline\" style=\"border-bottom-width:0.04em;\"></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.8278em;\"><span></span></span></span></span></span></span></span></span></span>","enumerator":"4","key":"ch9EFbrgQZ"},{"type":"paragraph","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"which translate to ","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"QUO4pWwF4X"},{"type":"text","value":"-2","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"cSt42Ejcj9"},{"type":"text","value":" in decimal as desired.","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"DtoZkzNZBC"}],"key":"oNOmJg582w"}],"key":"RQfAATBYMQ"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"subslide"}},"children":[{"type":"exercise","label":"ex:overflow","identifier":"ex:overflow","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"overflow","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"DMPQpJraRP"}],"key":"eMtH0GTho1"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"There is a subtlety when computing ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"yGfgw5zHme"},{"type":"inlineMath","value":"3 - 2","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mn>3</mn><mo>−</mo><mn>2</mn></mrow><annotation encoding=\"application/x-tex\">3 - 2</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7278em;vertical-align:-0.0833em;\"></span><span class=\"mord\">3</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">−</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6444em;\"></span><span class=\"mord\">2</span></span></span></span>","key":"WIgaC2atKr"},{"type":"text","value":" using binary addition because","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"A54Ctp02Oe"}],"key":"uN7Dg0ZiHB"},{"type":"math","value":"\\overbrace{011_2}^3 + \\overbrace{110_2}^{-2} = 1001_2","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"html":"<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mover><mover><mrow><mn>01</mn><msub><mn>1</mn><mn>2</mn></msub></mrow><mo stretchy=\"true\">⏞</mo></mover><mn>3</mn></mover><mo>+</mo><mover><mover><mrow><mn>11</mn><msub><mn>0</mn><mn>2</mn></msub></mrow><mo stretchy=\"true\">⏞</mo></mover><mrow><mo>−</mo><mn>2</mn></mrow></mover><mo>=</mo><mn>100</mn><msub><mn>1</mn><mn>2</mn></msub></mrow><annotation encoding=\"application/x-tex\">\\overbrace{011_2}^3 + \\overbrace{110_2}^{-2} = 1001_2</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:2.0935em;vertical-align:-0.15em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.9435em;\"><span style=\"top:-3.2924em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.2924em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">01</span><span class=\"mord\"><span class=\"mord\">1</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span></span></span><span class=\"svg-align\" style=\"top:-3.7444em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"stretchy\" style=\"height:0.548em;min-width:1.6em;\"><span class=\"brace-left\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class=\"brace-center\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class=\"brace-right\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span style=\"top:-4.7849em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">3</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">+</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:2.1519em;vertical-align:-0.15em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:2.0019em;\"><span style=\"top:-3.2924em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"mord mover\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:1.2924em;\"><span style=\"top:-3em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"mord\"><span class=\"mord\">11</span><span class=\"mord\"><span class=\"mord\">0</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span></span></span><span class=\"svg-align\" style=\"top:-3.7444em;\"><span class=\"pstrut\" style=\"height:3em;\"></span><span class=\"stretchy\" style=\"height:0.548em;min-width:1.6em;\"><span class=\"brace-left\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class=\"brace-center\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class=\"brace-right\" style=\"height:0.548em;\"><svg xmlns=\"http://www.w3.org/2000/svg\" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span><span style=\"top:-4.8432em;\"><span class=\"pstrut\" style=\"height:3.2924em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">−</span><span class=\"mord mtight\">2</span></span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.7944em;vertical-align:-0.15em;\"></span><span class=\"mord\">100</span><span class=\"mord\"><span class=\"mord\">1</span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em;\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em;\"><span class=\"pstrut\" style=\"height:2.7em;\"></span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2</span></span></span></span><span class=\"vlist-s\">​</span></span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em;\"><span></span></span></span></span></span></span></span></span></span></span>","enumerator":"5","key":"HVJuHvnwqT"},{"type":"paragraph","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"children":[{"type":"text","value":"which overflows to ","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"nBX0rIDskZ"},{"type":"text","value":"4","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"mFRIYP5WCq"},{"type":"text","value":" bits, a seemingly invalid binary representation. Fortunately, there is a simple fix so binary addition can still apply. Come up with such a fix that also works for other cases such as ","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"N7bQEOsbEG"},{"type":"inlineMath","value":"3-3","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mn>3</mn><mo>−</mo><mn>3</mn></mrow><annotation encoding=\"application/x-tex\">3-3</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7278em;vertical-align:-0.0833em;\"></span><span class=\"mord\">3</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">−</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6444em;\"></span><span class=\"mord\">3</span></span></span></span>","key":"lndMlGRfqL"},{"type":"text","value":", ","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"FujpU36DfS"},{"type":"inlineMath","value":"2-1","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mn>2</mn><mo>−</mo><mn>1</mn></mrow><annotation encoding=\"application/x-tex\">2-1</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7278em;vertical-align:-0.0833em;\"></span><span class=\"mord\">2</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">−</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6444em;\"></span><span class=\"mord\">1</span></span></span></span>","key":"CftnDdkXu5"},{"type":"text","value":", etc.","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"i70c2XEkdh"}],"key":"XBxpAJ4eAy"},{"type":"admonition","kind":"hint","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Hint","key":"DUvATx30t3"}],"key":"eylXB1OZMF"},{"type":"paragraph","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"See ","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"yZmDuBkC1u"},{"type":"link","url":"https://en.wikipedia.org/wiki/Two%27s_complement","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"two’s complement represenation","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"Kxe9HAE7Tg"}],"urlSource":"https://en.wikipedia.org/wiki/Two%27s_complement","data":{"page":"Two%27s_complement","wiki":"https://en.wikipedia.org/","lang":"en"},"internal":false,"protocol":"wiki","key":"Ih6mORZQdc"},{"type":"text","value":".","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"EoQeUCgefS"}],"key":"roXCro7lZl"}],"key":"U6MvDmKL7x"}],"enumerator":"5","html_id":"ex-overflow","key":"Y2X7riexHj"}],"key":"jVA7oxrEOM"},{"type":"block","kind":"notebook-content","data":{"deletable":false,"nbgrader":{"cell_type":"markdown","checksum":"ebfc611b93ad1ee08e4b194755df8279","grade":true,"grade_id":"fix-overflow","locked":false,"points":1,"schema_version":3,"solution":true,"task":false},"slideshow":{"slide_type":"-"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"YOUR ANSWER HERE","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"iLmWv4Ubdb"}],"key":"XLAcP6zm34"}],"key":"uenQy6m280"},{"type":"block","kind":"notebook-content","data":{"slideshow":{"slide_type":"slide"}},"children":[{"type":"heading","depth":2,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Logic Gates","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"B1NyKoCjxb"}],"identifier":"logic-gates","label":"Logic Gates","html_id":"logic-gates","implicit":true,"key":"AXDIbX8phc"}],"key":"yASvtkubsE"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"subslide"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"A computer is built from transistors that operates on binary states ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"fvRJExELh4"},{"type":"emphasis","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"on/off","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"PKmvKMt4gn"}],"key":"nFF0RFcLsg"},{"type":"text","value":",\nwhich is also represented as bits ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"w0TTyDo6Xg"},{"type":"emphasis","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"1/0","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"vAyRQTFFTq"}],"key":"qFGyt9BQpj"},{"type":"text","value":", or the ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"Qm2ikdpvEk"},{"type":"link","url":"https://en.wikipedia.org/wiki/Boolean_data_type#:~:text=In%20computer%20science%2C%20the%20Boolean,of%20logic%20and%20Boolean%20algebra.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"emphasis","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"boolean","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"yfAjXmWr8E"}],"key":"ExOutaG8L0"}],"urlSource":"https://en.wikipedia.org/wiki/Boolean_data_type#:~:text=In%20computer%20science%2C%20the%20Boolean,of%20logic%20and%20Boolean%20algebra.","data":{"page":"Boolean_data_type#:~:text=In%20computer%20science%2C%20the%20Boolean,of%20logic%20and%20Boolean%20algebra.","wiki":"https://en.wikipedia.org/","lang":"en"},"internal":false,"protocol":"wiki","key":"d0W1uiWE97"},{"type":"text","value":" value ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"p2vScB2Ay1"},{"type":"emphasis","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"true/false","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"V8k3jQtSzf"}],"key":"afiyxrHmZV"},{"type":"text","value":". Play with the following simulator to see some examples.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"tUvuPQpjjU"}],"key":"wueeqEa8uw"}],"key":"NDGXB0YS1D"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"card","children":[{"type":"header","children":[{"type":"paragraph","children":[{"type":"link","url":"https://logic.ly/demo/","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"Logic simulator","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"jUuINFbjR4"}],"urlSource":"https://logic.ly/demo/","key":"IleHV35YyE"}],"key":"QyT75SCtEc"}],"key":"SCKd3sivAh"},{"type":"list","ordered":true,"start":1,"spread":false,"position":{"start":{"line":4,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"Click the logic simulator header above.","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"K2xvBnyLDb"}],"key":"dgTnAzxpoJ"},{"type":"listItem","spread":true,"position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"Select ","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"DyLAdvIAP4"},{"type":"emphasis","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"1-Bit Full Adder","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"zker8OKngI"}],"key":"Wf0rb3CYig"},{"type":"text","value":".","position":{"start":{"line":5,"column":1},"end":{"line":5,"column":1}},"key":"MGZmuwA4zR"}],"key":"WyrOzaQtEi"},{"type":"listItem","spread":true,"position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"text","value":"Change the input and observe the output.","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"sehCqkOoQR"}],"key":"fulNNf7hQp"}],"key":"mXWeAMqQtl"}],"key":"g6sA0gFkLo"}],"key":"YfGIfsfdW7"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"subslide"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"crossReference","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Table ","key":"xCHhSJnhSm"},{"type":"text","value":"4","key":"DjHM9pXpYj"}],"identifier":"tab:adder","label":"tab:adder","kind":"table","template":"Table %s","enumerator":"4","resolved":true,"html_id":"tab-adder","key":"fPtVbjyPqm"},{"type":"text","value":" gives the input and output relationship of a simpler adder, called the half adder, which computes the addition of two input bits ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"lFmWyDv1wE"},{"type":"inlineMath","value":"A","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>A</mi></mrow><annotation encoding=\"application/x-tex\">A</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span></span></span></span>","key":"XyGqvg8PAw"},{"type":"text","value":" and ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"qKN0jHeQ65"},{"type":"inlineMath","value":"B","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>B</mi></mrow><annotation encoding=\"application/x-tex\">B</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span></span></span></span>","key":"A07dqMMg9v"},{"type":"text","value":" as","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"wNFyv3FqKX"}],"key":"slPBDnpjdS"},{"type":"math","value":"A + B = C\\circ S","position":{"start":{"line":3,"column":1},"end":{"line":5,"column":1}},"html":"<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>A</mi><mo>+</mo><mi>B</mi><mo>=</mo><mi>C</mi><mo>∘</mo><mi>S</mi></mrow><annotation encoding=\"application/x-tex\">A + B = C\\circ S</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.7667em;vertical-align:-0.0833em;\"></span><span class=\"mord mathnormal\">A</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">+</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.07153em;\">C</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">∘</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em;\">S</span></span></span></span></span>","enumerator":"6","key":"NB770O2l4Y"},{"type":"paragraph","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"children":[{"type":"text","value":"where ","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"WxAows63cK"},{"type":"inlineMath","value":"C","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>C</mi></mrow><annotation encoding=\"application/x-tex\">C</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.07153em;\">C</span></span></span></span>","key":"kePrYWF28s"},{"type":"text","value":" and ","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"PotEvFFhHX"},{"type":"inlineMath","value":"S","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>S</mi></mrow><annotation encoding=\"application/x-tex\">S</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em;\">S</span></span></span></span>","key":"kr0t5ziSTB"},{"type":"text","value":" are the output bits, and ","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"E9q2Xt06wM"},{"type":"inlineMath","value":"C\\circ S","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>C</mi><mo>∘</mo><mi>S</mi></mrow><annotation encoding=\"application/x-tex\">C\\circ S</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.07153em;\">C</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span><span class=\"mbin\">∘</span><span class=\"mspace\" style=\"margin-right:0.2222em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em;\">S</span></span></span></span>","key":"P9ZI3YrsHY"},{"type":"text","value":" is the concatenation of two bits ","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"xQuXkpKJVj"},{"type":"inlineMath","value":"C","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>C</mi></mrow><annotation encoding=\"application/x-tex\">C</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.07153em;\">C</span></span></span></span>","key":"Zitxx6X2lI"},{"type":"text","value":" and ","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"EhPIzeoX9i"},{"type":"inlineMath","value":"S","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>S</mi></mrow><annotation encoding=\"application/x-tex\">S</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em;\">S</span></span></span></span>","key":"XXE0hpfmAj"},{"type":"text","value":".","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"sh6hZQjOMw"}],"key":"LsEBzzbTMF"}],"key":"zw62NQHyK8"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"container","kind":"table","children":[{"type":"caption","children":[{"type":"paragraph","children":[{"type":"captionNumber","kind":"table","label":"tab:adder","identifier":"tab:adder","html_id":"tab-adder","enumerator":"4","children":[{"type":"text","value":"Table ","key":"gOY7d3Mnb1"},{"type":"text","value":"4","key":"uUbCMcPZIM"},{"type":"text","value":":","key":"m95ZTLdzj5"}],"template":"Table %s:","key":"J2NmQbqV4P"},{"type":"text","value":"Adder.","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"naE8rcCZ7U"}],"key":"kxWbHTp2ZZ"}],"key":"x2DEquqYWR"},{"type":"table","children":[{"type":"tableRow","children":[{"type":"tableCell","header":true,"children":[{"type":"text","value":"A","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"ZmndzcTADI"}],"key":"Ry4YNPH8Gm"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"B","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"D2uJVQOjvj"}],"key":"Zxmkx6asif"},{"type":"tableCell","header":true,"children":[{"type":"text","value":"C","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"G0x0PfWXJQ"},{"type":"text","value":"∘","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"EJt2LyDh9c"},{"type":"text","value":"S","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"BYSSALZTyl"}],"key":"v6YcRozVHn"}],"key":"x3TYbvyKjc"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"0","position":{"start":{"line":10,"column":1},"end":{"line":10,"column":1}},"key":"foukDXpfau"}],"key":"gj3A7hILeq"},{"type":"tableCell","children":[{"type":"text","value":"0","position":{"start":{"line":11,"column":1},"end":{"line":11,"column":1}},"key":"cHbJPiOI4p"}],"key":"FimstNnTkv"},{"type":"tableCell","children":[{"type":"text","value":"00","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"psBpIjq1yM"}],"key":"xeFF2JhfGy"}],"key":"vZWpx6tA1X"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"0","position":{"start":{"line":14,"column":1},"end":{"line":14,"column":1}},"key":"SaCXCvFBIZ"}],"key":"fvGC6CnjJM"},{"type":"tableCell","children":[{"type":"text","value":"1","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"HcxKQluRdC"}],"key":"ZfeQgmvpd2"},{"type":"tableCell","children":[{"type":"text","value":"01","position":{"start":{"line":16,"column":1},"end":{"line":16,"column":1}},"key":"ShvhjKQ2s7"}],"key":"iCebMpkk1i"}],"key":"Bg70NdbYd9"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"1","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"X4VefZbSE8"}],"key":"n54kfdksqO"},{"type":"tableCell","children":[{"type":"text","value":"0","position":{"start":{"line":19,"column":1},"end":{"line":19,"column":1}},"key":"D6scYcsHeq"}],"key":"v4JQfQ5cDd"},{"type":"tableCell","children":[{"type":"text","value":"01","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"key":"CvEFX6jyoQ"}],"key":"SffqBp17pp"}],"key":"j3nOjvzytn"},{"type":"tableRow","children":[{"type":"tableCell","children":[{"type":"text","value":"1","position":{"start":{"line":22,"column":1},"end":{"line":22,"column":1}},"key":"N4tHUHEgty"}],"key":"mkBNl3F9Sk"},{"type":"tableCell","children":[{"type":"text","value":"1","position":{"start":{"line":23,"column":1},"end":{"line":23,"column":1}},"key":"qJIi66nZgT"}],"key":"Q0VmUStsBP"},{"type":"tableCell","children":[{"type":"text","value":"10","position":{"start":{"line":24,"column":1},"end":{"line":24,"column":1}},"key":"C3Ed39ehbG"}],"key":"AdHYxC9B1Z"}],"key":"q51ARn64lV"}],"key":"rNzLQO26zc"}],"label":"tab:adder","identifier":"tab:adder","enumerator":"4","html_id":"tab-adder","key":"cfXen3uaXA"}],"key":"cqSIqenuOk"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"fragment"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"The operation can be built using transistors, called ","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"iRIvfFjAjL"},{"type":"link","url":"https://en.wikipedia.org/wiki/Logic_gate","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"emphasis","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"logic gates","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"vDDk5pSUQ5"}],"key":"eFd1Mm3hQL"}],"urlSource":"https://en.wikipedia.org/wiki/Logic_gate","data":{"page":"Logic_gate","wiki":"https://en.wikipedia.org/","lang":"en"},"internal":false,"protocol":"wiki","key":"Hnb8HdHYoV"},{"type":"text","value":", that can carry out basic logic operations such as","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"qHFJ0pG5on"}],"key":"OVlH0v5wZa"},{"type":"list","ordered":false,"spread":false,"position":{"start":{"line":3,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"inlineMath","value":"A \\operatorname{AND} B","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>A</mi><mi mathvariant=\"normal\">AND</mi><mo>⁡</mo><mi>B</mi></mrow><annotation encoding=\"application/x-tex\">A \\operatorname{AND} B</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop\"><span class=\"mord mathrm\">AND</span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span></span></span></span>","key":"Hjsp0zvL5A"},{"type":"text","value":": which returns ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"KS4kRXD0q2"},{"type":"text","value":"1","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"VUFK3IKDyG"},{"type":"text","value":" if and only if both ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"NJIFxLc4aj"},{"type":"inlineMath","value":"A","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>A</mi></mrow><annotation encoding=\"application/x-tex\">A</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span></span></span></span>","key":"y0Pey8RlxL"},{"type":"text","value":" and ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"NSUZWFWYGu"},{"type":"inlineMath","value":"B","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>B</mi></mrow><annotation encoding=\"application/x-tex\">B</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span></span></span></span>","key":"GWEWhrbuGA"},{"type":"text","value":" are ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"aiyBj5T9fT"},{"type":"text","value":"1","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"eUyyOEE0Hj"},{"type":"text","value":", and ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"HzyPS0zPvS"},{"type":"text","value":"0","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"yfPA6kkSDk"},{"type":"text","value":" otherwise.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"TxxgxU2R58"}],"key":"QEyQNqCrkQ"},{"type":"listItem","spread":true,"position":{"start":{"line":4,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"inlineMath","value":"A \\operatorname{XOR} B","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>A</mi><mi mathvariant=\"normal\">XOR</mi><mo>⁡</mo><mi>B</mi></mrow><annotation encoding=\"application/x-tex\">A \\operatorname{XOR} B</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mop\"><span class=\"mord mathrm\">XOR</span></span><span class=\"mspace\" style=\"margin-right:0.1667em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span></span></span></span>","key":"aVmnwKt0KP"},{"type":"text","value":": which returns ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"JWViMXOUf0"},{"type":"text","value":"1","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"AeBaGkQrHV"},{"type":"text","value":" if and only if either ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"DgNWIJEBjn"},{"type":"inlineMath","value":"A","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>A</mi></mrow><annotation encoding=\"application/x-tex\">A</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span></span></span></span>","key":"oRE6m4Mztk"},{"type":"text","value":" and ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"Qub1ObWD1N"},{"type":"inlineMath","value":"B","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>B</mi></mrow><annotation encoding=\"application/x-tex\">B</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span></span></span></span>","key":"j9FXnPMLLW"},{"type":"text","value":" are ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"s8QZhpeNGE"},{"type":"text","value":"1","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"g39hDiXGY1"},{"type":"text","value":" but not both.","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"ciEdiZBiSF"}],"key":"AldfwPsqlX"}],"key":"bEohvaqdEF"},{"type":"paragraph","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"children":[{"type":"text","value":"The input and output relationships are listed below:","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"Oh2GE1fqpG"}],"key":"qN0hSgqhKM"}],"key":"LQrgmbAC9v"},{"type":"block","kind":"notebook-code","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"code","lang":"python","executable":true,"value":"from pandas import DataFrame\n\nDataFrame(\n    [[A, B, A & B, A ^ B] for A in (0, 1) for B in (0, 1)],\n    columns=[\"A\", \"B\", \"A AND B\", \"A XOR B\"],\n)","key":"Hz37quaZG3"},{"type":"output","id":"VT19qxziTB-kdKgdU2FWg","data":[],"key":"FvYCe7kf3x"}],"key":"WY8uWysfxT"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"fragment"}},"children":[{"type":"admonition","kind":"note","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Note","key":"fLSBdK8ww7"}],"key":"O0unKxyEia"},{"type":"paragraph","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"children":[{"type":"text","value":"The logical functions are computed using ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"pMdkgiepIv"},{"type":"crossReference","label":"bitwise operator","identifier":"term-bitwise operator","children":[{"type":"text","value":"bitwise operators","key":"n2xzicooP1"}],"kind":"definitionTerm","template":"{name}","resolved":true,"html_id":"term-bitwise-operator","key":"d2Lhu0OQ5C"},{"type":"text","value":" ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"vgxoAg8ue6"},{"type":"inlineCode","value":"&","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"ePz5vBnlTj"},{"type":"text","value":" and ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"mPcieeFgd8"},{"type":"inlineCode","value":"^","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"ckCBTwe93E"},{"type":"text","value":", and the result is stored as a ","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"yNtPqs47Xi"},{"type":"inlineCode","value":"DataFrame","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"HikbtRCaYk"},{"type":"text","value":" object, which is a useful tool for data analysis to be explained later in the course.","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"K80sOtTMtH"}],"key":"PjWGwrJlBi"}],"key":"Ax6uPg5euY"}],"key":"z5WU3oKrWt"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"subslide"}},"children":[{"type":"exercise","label":"ex:adder","identifier":"ex:adder","enumerated":true,"children":[{"type":"admonitionTitle","children":[{"type":"text","value":"adder","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"ElzXUoMy4w"}],"key":"u2shnaCiY7"},{"type":"paragraph","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"children":[{"type":"text","value":"What is the logic in computing ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"IFcjzjNrMk"},{"type":"inlineMath","value":"C","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>C</mi></mrow><annotation encoding=\"application/x-tex\">C</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.07153em;\">C</span></span></span></span>","key":"kny3zVLV5P"},{"type":"text","value":" and ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"CBjJmjfJRf"},{"type":"inlineMath","value":"S","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>S</mi></mrow><annotation encoding=\"application/x-tex\">S</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em;\">S</span></span></span></span>","key":"dv5qt2sE5f"},{"type":"text","value":" from ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"CIAQrCNxBW"},{"type":"inlineMath","value":"A","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>A</mi></mrow><annotation encoding=\"application/x-tex\">A</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span></span></span></span>","key":"PVPi3T1CbL"},{"type":"text","value":" and ","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"O6jTCXgRrX"},{"type":"inlineMath","value":"B","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"html":"<span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mi>B</mi></mrow><annotation encoding=\"application/x-tex\">B</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.05017em;\">B</span></span></span></span>","key":"WjyRfsDtZl"},{"type":"text","value":"? Use the logic gates AND and XOR only.","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"n9irkPlwAt"}],"key":"WR4quHaZ6B"}],"enumerator":"6","html_id":"ex-adder","key":"WsTcTrfmRq"}],"key":"mmGS8sYa9K"},{"type":"block","kind":"notebook-content","data":{"deletable":false,"editable":true,"nbgrader":{"cell_type":"markdown","checksum":"1b3cda11465c28407e17282a89a70995","grade":true,"grade_id":"adder","locked":false,"points":1,"schema_version":3,"solution":true,"task":false},"slideshow":{"slide_type":"-"}},"children":[{"type":"paragraph","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"YOUR ANSWER HERE","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"UvmAi1QLbY"}],"key":"B2gX4cZ0SL"}],"key":"QaVgJl2VUJ"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":"subslide"}},"children":[{"type":"admonition","kind":"seealso","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"See Also","key":"YMuUKKAJR6"}],"key":"QguSwi4gQb"},{"type":"paragraph","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"If you play minecraft, you can build the following devices based on how computers are built from logic gates:","position":{"start":{"line":2,"column":1},"end":{"line":2,"column":1}},"key":"etoYXpIWFZ"}],"key":"OGdc8bz9E6"},{"type":"grid","columns":[1,1,2,2],"children":[{"type":"card","children":[{"type":"header","children":[{"type":"paragraph","children":[{"type":"text","value":"An adder for binary addition","position":{"start":{"line":7,"column":1},"end":{"line":7,"column":1}},"key":"RcbzI0igyX"}],"key":"NhsfzAiWgv"}],"key":"eX9i7wxwPn"},{"type":"iframe","src":"https://www.youtube.com/embed/vtpTri-PZXY","width":"100%","key":"QGviyKUaL2"},{"type":"footer","children":[{"type":"paragraph","children":[{"type":"link","url":"https://youtu.be/vtpTri-PZXY","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"children":[{"type":"text","value":"open in new tab","position":{"start":{"line":8,"column":1},"end":{"line":8,"column":1}},"key":"VsOimyukcr"}],"urlSource":"https://youtu.be/vtpTri-PZXY","key":"JqBGv0UTvM"}],"key":"kTIDGVtcLw"}],"key":"E4fQ7E3nHP"}],"key":"p7ZIQ7nRKi"},{"type":"card","children":[{"type":"header","children":[{"type":"paragraph","children":[{"type":"text","value":"A calculator for calculus","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"np2hr0w8ml"}],"key":"ZT7S5DLPvr"}],"key":"uP9AkfzLQr"},{"type":"iframe","src":"https://www.youtube.com/embed/5NzIt9sns6o","width":"100%","key":"Kw0uDGGoyB"},{"type":"footer","children":[{"type":"paragraph","children":[{"type":"link","url":"https://youtu.be/5NzIt9sns6o","position":{"start":{"line":19,"column":1},"end":{"line":19,"column":1}},"children":[{"type":"text","value":"open in new tab","position":{"start":{"line":19,"column":1},"end":{"line":19,"column":1}},"key":"pDdyL9Egsv"}],"urlSource":"https://youtu.be/5NzIt9sns6o","key":"fbXJdh4VpX"}],"key":"HETngQiSpz"}],"key":"q66EoKznRR"}],"key":"VqNVhQJsK7"}],"key":"IpmOshifVT"}],"key":"GgKJ9M63fD"}],"key":"WytigkfPYF"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"heading","depth":2,"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"children":[{"type":"text","value":"Glossary","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":1}},"key":"r4ZHt7MD1m"}],"identifier":"glossary","label":"Glossary","html_id":"glossary","implicit":true,"key":"WlncVXQVjP"}],"key":"CoJMiv5CKM"},{"type":"block","kind":"notebook-content","data":{"editable":true,"slideshow":{"slide_type":""}},"children":[{"type":"glossary","children":[{"type":"definitionList","position":{"start":{"line":3,"column":1},"end":{"line":22,"column":1}},"children":[{"type":"definitionTerm","position":{"start":{"line":3,"column":1},"end":{"line":2,"column":1}},"children":[{"type":"text","value":"algorithm","position":{"start":{"line":3,"column":1},"end":{"line":3,"column":1}},"key":"o6MMxellB9"}],"label":"algorithm","identifier":"term-algorithm","html_id":"term-algorithm","indexEntries":[{"entry":"algorithm"}],"key":"HABlroofJt"},{"type":"definitionDescription","position":{"start":{"line":4,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"An algorithm is a set of instructions that a computer program follows to solve a problem or complete a task. It is a step-by-step approach designed to be efficient and accurate.","position":{"start":{"line":4,"column":1},"end":{"line":4,"column":1}},"key":"rMHOJMhNMC"}],"key":"qlI7Uh9DB9"},{"type":"definitionTerm","position":{"start":{"line":6,"column":1},"end":{"line":5,"column":1}},"children":[{"type":"text","value":"bitwise operator","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"tJOQe55AJw"}],"label":"bitwise operator","identifier":"term-bitwise operator","html_id":"term-bitwise-operator","indexEntries":[{"entry":"bitwise operator"}],"key":"eZ5bC5cTiA"},{"type":"definitionDescription","position":{"start":{"line":6,"column":1},"end":{"line":8,"column":1}},"children":[{"type":"text","value":"Bitwise operators are used to manipulate individual bits of binary numbers. They allow for the manipulation of data at a low level, such as setting or clearing specific bits, shifting bits left or right, or performing logical operations on bits.","position":{"start":{"line":6,"column":1},"end":{"line":6,"column":1}},"key":"rSgk4q8Ytb"}],"key":"Hwtmm9vHwd"},{"type":"definitionTerm","position":{"start":{"line":9,"column":1},"end":{"line":8,"column":1}},"children":[{"type":"text","value":"composite data type","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"TmJeS9Ejf1"}],"label":"composite data type","identifier":"term-composite data type","html_id":"term-composite-data-type","indexEntries":[{"entry":"composite data type"}],"key":"tJPvxf1Yl0"},{"type":"definitionDescription","position":{"start":{"line":9,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"A composite data type groups related data into a single unit so that they can be easily stored and manipulated together.","position":{"start":{"line":9,"column":1},"end":{"line":9,"column":1}},"key":"wZ9NcqBmic"}],"key":"dekeV27JIz"},{"type":"definitionTerm","position":{"start":{"line":12,"column":1},"end":{"line":11,"column":1}},"children":[{"type":"text","value":"conditional","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"cWuf4GdBOW"}],"label":"conditional","identifier":"term-conditional","html_id":"term-conditional","indexEntries":[{"entry":"conditional"}],"key":"RHcrjS58kt"},{"type":"definitionDescription","position":{"start":{"line":12,"column":1},"end":{"line":14,"column":1}},"children":[{"type":"text","value":"A conditional statement is used to perform different actions based on different conditions. It allows the program to make decisions and execute specific code blocks based on the evaluation of a given condition.","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"tMdIwlA4ua"}],"key":"ArrjkXvmqV"},{"type":"definitionTerm","position":{"start":{"line":15,"column":1},"end":{"line":14,"column":1}},"children":[{"type":"text","value":"iteration","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"NAMntS5lSi"}],"label":"iteration","identifier":"term-iteration","html_id":"term-iteration","indexEntries":[{"entry":"iteration"}],"key":"njmJawvJXA"},{"type":"definitionDescription","position":{"start":{"line":15,"column":1},"end":{"line":17,"column":1}},"children":[{"type":"text","value":"An iteration is a repeated execution until a condition is met. It allows for the efficient repetition of tasks without the need for writing the same code multiple times.","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"Xs4itSq0ZC"}],"key":"vLgkY5HJ04"},{"type":"definitionTerm","position":{"start":{"line":18,"column":1},"end":{"line":17,"column":1}},"children":[{"type":"text","value":"library","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"nFtDcjiAjD"}],"label":"library","identifier":"term-library","html_id":"term-library","indexEntries":[{"entry":"library"}],"key":"LghZpSz3GO"},{"type":"definitionDescription","position":{"start":{"line":18,"column":1},"end":{"line":20,"column":1}},"children":[{"type":"text","value":"A library is a collection of pre-written code that developers can use to perform common tasks. It contains functions, classes, and other reusable code that can be integrated into a larger software application, saving time and effort.","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"xeeWUFUUOC"}],"key":"oHEPn9yB1O"},{"type":"definitionTerm","position":{"start":{"line":21,"column":1},"end":{"line":20,"column":1}},"children":[{"type":"text","value":"pseudocode","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"YalWprCQbE"}],"label":"pseudocode","identifier":"term-pseudocode","html_id":"term-pseudocode","indexEntries":[{"entry":"pseudocode"}],"key":"tVIHr8WgrN"},{"type":"definitionDescription","position":{"start":{"line":21,"column":1},"end":{"line":22,"column":1}},"children":[{"type":"text","value":"Pseudocode is a high-level description of a program or algorithm, using natural language and code-like syntax to express logic without being bound to a specific programming language. It is used during planning and design phases of software development.","position":{"start":{"line":21,"column":1},"end":{"line":21,"column":1}},"key":"TKiwfDpAZC"}],"key":"i5sXumOegW"}],"key":"pJbIvMbsqf"}],"key":"VnXwdWosMa"}],"key":"O2PegSS9kr"}],"key":"fuvBURR1Gb"},"references":{"cite":{"order":[],"data":{}}},"footer":{"navigation":{"prev":{"title":"Introduction to Computer Programming","url":"/introduction-to-computer-programming","group":"Lecture 1"},"next":{"title":"Debugger","url":"/debugger","group":"Lab 1"}}},"domain":"http://localhost:3000"}