Question: Using Python 3.6.0 Consider the following code. It is supposed to take a list of numbers from the user. Make a new list containing only

Using Python 3.6.0

Consider the following code. It is supposed to take a list of numbers from the user. Make a new list containing only the numbers which are multiples of 2. Finally it is supposed to print these numbers 5 numbers in a line.

It uses two functions ispow2 which takes a number n and returns the boolean value True if that number is a power of 2 otherwise False.

print5 which takes a list and prints the list 5 numbers per line separated by spaces.

Please write code the correct ispow2 and print5 functions and submit the complete program. Everything in main() is already correct.

def ispow2(n):

def print5(lst):

def main(): lst = input("Please enter the list") nums = [int(j) for j in lst.split()]

newlst = [] for i in nums: if (ispow2(i)): newlst.append(i)

print5(newlst) main()

Sample output:

Please enter the list:2 4 8 5 7 9 2 4 8 2 16 17

2 4 8 2 4

8 2 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!