What will the following code return? l = {i%2 for i in range(10)}
Explanation
Provided expression is a set comprehension. It first iterates over numbers from 0 to 9 and calculates the remainder from division by 2 for each of them. Remainders are later collected into a set. Therefore {0, 1} is correct answer

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Python quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes