InterviewSolution
Saved Bookmarks
| 1. |
Write a program that creates a list of numbers from 1 to 50 that are either divisible by 3 or divisible by 6? |
|
Answer» n = [ ] s = [ ] for x in range(1, 51): n.append(x) for x in range(1, 51): if(x%3 == 0) or (x % 6 == 0): s.append(x) print(“The numbers divisible by 3 or 6 is “ , s) Output: The numbers divisible by 3 or 6 is [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48] |
|