KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Science

Write a program that creates a list of all the integers less than 100 that are multiples of 3 or 5.

Python

Python List Manipulation

7 Likes

Answer

a = []
for i in range(0,100):
    if (i % 3 == 0) or (i % 5 == 0) :
        a.append(i) 
print(a)

Output

[0, 3, 5, 6, 9, 10, 12, 15, 18, 20, 21, 24, 25, 27, 30, 33, 35, 36, 39, 40, 42, 45, 48, 50, 51, 54, 55, 57, 60, 63, 65, 66, 69, 70, 72, 75, 78, 80, 81, 84, 85, 87, 90, 93, 95, 96, 99]

Answered By

3 Likes


Related Questions