You are on page 1of 1

PAMANTASAN NG LUNGSOD NG MUNTINLUPA

COLLEGE OF INFORMATION TECHNOLOGY AND COMPUTER STUDIES

University Road, Poblacion, Muntinlupa City

Sucgang, Richard L. PROFELEC2 – Python Programming


BSIT – 3H Ms. Kaycee R. Mendez, MIT, LPT

Week 10 – Worksheet

Directions: Write the value of the following list comprehension.

1. numbers = [8, 12, 6, 15, 9, 20]


[num for num in numbers if num > 10]
[12, 15, 20]

2. numbers = [5, -8, 10, -3, -12, 7]


[num for num in numbers if num < 0]
[-8, -3, -12]

3. [x for x in range(1, 51) if x % 7 == 0]


[7, 14, 21, 28, 35, 42, 49]

4. [i for i in range(1, 21) if i % 2 == 1]


[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

5. [a for a in range(1, 101) if a % 3 == 0 and a % 5 == 0]


[15, 30, 45, 60, 75, 90]

Week 10 – List Comprehension

You might also like