Lecture 37 – Practice Exercises 9 CMPT 120 Lecture 37 – Practice Exercises 9
Question 1 How many distinct numbers can I represent with … 1 bit? What are these numbers? 4 bits? What are these numbers (in binary)? How many distinct numbers can I represent with 7 bits? These numbers range from ______ to _______ How many distinct numbers can I represent with 1 byte? How many distinct numbers can I represent with 32 bits? These numbers range from ______ to _______________
Question 2 – Convert the following numbers Convert 10011011 into an integer (decimal number): a) What is the binary equivalent of 57? b) What is the binary equivalent of 157? a) Express 10011011 as an hexadecimal number: b) Express 1011110 as an hexadecimal number:
Question 3 Translate the following message: 01000111 01101111 01101111 01100100 00100000 01101100 01110101 01100011 01101011 00100000 01101001 01101110 00100000 01111001 01101111 01110101 01110010 00100000 01100110 01101001 01101110 01100001 01101100 00100000 01100101 01111000 01100001 01101101 01110011 00100001 0001010 Answer:
Question 4 Problem Statement Let’s write a binary-decimal converter in Python How would we go about solving this problem? Algorithm:
Question 5 Problem Statement Write two Python functions to find the minimum number in a list The first function must compare each number to every other number on the list It complexity must be O(n2) The second function must be linear O(n)