Name: _________________Grade: n.net



Name: _________________Grade: __________Title: Binary to Decimal ConversionOBJECTIVESThis iLab demonstrates how to create a binary-to-decimal converter using Python. The challenge in this iLab is to create an 8-bit binary-to-decimal converter from the given 4-bit binary-to-decimal converter. II.DESCRIPTIONThis program uses a WHILE loop for the entry zeros and ones. Take a look at the program segment below.Line 1: while True:Line 2: a = input(‘Enter 1st bit [1 or 0] (right most bit): ‘)Line 3: if a < 2: breakLine 1 creates a WHILE loop that is executed indefinitely. The loop (Line 1–Line 3) will execute over and over again until the break command on Line 3 is executed. Line 2 will accept a number into variable a. Line 3 will check to see whether variable a is less than 2. If variable a is not less than 2, then continue to ask the user for an input. If variable a is less than 2, then get out of this WHILE loop. The correct entry is entered. A binary number contains ones and zeros.III.PROCEDUREBoot up the Raspberry Pi (RPi). Open IDLE.Enter the program below.Name = ‘Put Your Name Here’Class = ‘ECT109’Assignment = ‘Week 3 Lab 2’#------------------------------------------------------------------ # Convert 4-bit binary number to decimal#------------------------------------------------------------------print Nameprint Classprint Assignmentprintwhile True: bit0 = input(‘Enter bit0 [1 or 0] (right most bit): ‘) if bit0 < 2: breakwhile True: bit1 = input(‘Enter bit1 [1 or 0]: ‘) if bit1 < 2: breakwhile True: bit2 = input(‘Enter bit2 [1 or 0]: ‘) if bit2 < 2: breakwhile True: bit3 = input(‘Enter bit3 [1 or 0]: ‘) if bit3 < 2: breakx = (bit0*1) + (bit1*2) + (bit2*4) + (bit3*8)print ‘Decimal value is ‘,xThis Python program will convert any 4-bit binary number to decimal. Your assignment is to modify the above program to convert any 8-bit binary number to decimal.Save your file as FiLastNameLab3-2.py.Run your program.Fix any errors.Upload the completed Python program (FiLastNameLab3-2.py) to the weekly iLab Dropbox. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download