Q. Use a list comprehension to create a list, CB4. The comprehension should consist of the cubes of the numbers 1 through 10 only if the cube is evenly divisible by four. Finally, print that list to the console.
Note that in this case, the cubed number should be evenly divisible by 4, not the original number.
Answer :-
CB4 = [i for i in range (1,11) if (i ** 3) % 4 == 0 ] print(CB4)
Output :-
[2, 4, 6, 8, 10]
>>>
Credit :- Jinsu
#Correct Answer:
ReplyDeleteCB4 = [i for i in range (1,11) if (i ** 3) % 4 == 0 ]
print(CB4)
Yes, I will correct it.
DeleteThanks for giving credit to me and updating the answer.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )