Question: do it in python pls Part I: Setting Bits (10 points) Write a function set bits (), which takes two arguments, in this order: num:
do it in python pls


Part I: Setting Bits (10 points) Write a function set bits (), which takes two arguments, in this order: num: a positive integ 2 bits.to set: a list of non-negative integers (i.e.. positive integers and possibly zero). Each integer is guaranteed to be less than the number of bits in the binary representation of nu The function iterates over the bits.to-set list, treating each value in the list as a bit position in the binary representation of num. The function then sets a 1 at each such bit position in num To make this a little easier to understand, suppose that num is 1101101001101 andbits.to.set is [0, 4, 7]. This means we want to set the bits at positions 0, 2, 4 and 7 in num to 1. Therefore, 2, 1101101001100 is changed to 1101111011101 where the asterisks indicate the four bit positions we are attempting to set
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
