Question: Problem 1 (Powers of Two Without Going Over) Write and test a function ced pow_of_two() that takes a positive integer num as the input

Problem 1 (Powers of Two Without Going Over) Write and test a function ced pow_of_two() that takes a positive integer num as the input parameter and returns another integer that is the largest power of 2 and is less than or equal to num. For example, 1, 2, 4, 8, 16, 32.. are numbers that are the powers of 2, but 3, 5, 6, 7, 9, 10.. are not. Some sample outputs are here to test. pow_of_two (1) 1 2 8 16 32 pow_of_two(2) pow_of_two (12) pow_of_two(20) pow_of_two (63) pow_of_two (284) 256
Step by Step Solution
There are 3 Steps involved in it
def powoftwonum power 0 while num 2 num 2 power 1 ret... View full answer
Get step-by-step solutions from verified subject matter experts
