Title: Boolean Functions

Title: Boolean Functions

<p> ECT109 Week 4 iLab 2 Page 1 of 2</p><p>Name: ______Grade: ______</p><p>Title: Boolean Functions</p><p>I. OBJECTIVES</p><p>This iLab uses the Python Boolean functions to perform Boolean operations on numerical values. The challenge in this lab is to use the OR and XOR Boolean functions in addition to the given AND Boolean function.. </p><p>II. DESCRIPTION</p><p>George Boole pioneered a mathematical concept known as Boolean expressions, or Boolean algebra. Four of the basic Boolean operation are the AND, the OR, the XOR, and the NOT operations. Programs use these operations to evaluate the relationship between variables and make decisions based on those relationships. Comparing two or more variables, bitwise, results in either a True (1) or False (0) outcome.</p><p>Bitwise operations Python operator Example AND & n & m OR | a | b XOR ^ e ^ f</p><p>Table 1 - Python Operators</p><p> to display a number function Example in binary bin(x) bin(5) = 0b101 In hexadecimal 0x%x ‘0x%x’ %46 = 0x2e</p><p>Table 2 - Number Conversions</p><p>III. PROCEDURE</p><p>1. Boot up the Raspberry Pi (RPi). </p><p>2. Open IDLE.</p><p>3. Enter the program below.</p><p>Name = ‘Put Your Name Here’</p><p>Class= ‘ECT109’</p><p>Assignment = ‘Week 4 Lab 2’ ECT109 Week 4 iLab 2 Page 2 of 2</p><p>#------</p><p># Boolean bitwise AND operator</p><p>#------</p><p> print Name</p><p> print Class</p><p> print Assignment</p><p> print</p><p> print 'AND operator' n = input(‘Enter 1st Number: ‘) m = input(‘Enter 2nd Number: ‘) print n, bin(n), '0x%x' % n print m, bin(m), '0x%x' % m x = n & m print n, 'AND', m, ' = ', x, bin(x), '0x%x' % x print</p><p>4. This Python program will perform the AND bitwise operator. Your assignment is to add to the above program the OR and XOR bitwise operators.</p><p>5. Verify your results.</p><p>6. Upload the completed Python program (FiLastNameLab4-2.py) to the weekly iLab Dropbox.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us