added 7-10
This commit is contained in:
21
basic programming/2nd task/7.py
Normal file
21
basic programming/2nd task/7.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Q7
|
||||
|
||||
# Initiallize variables
|
||||
count = 0
|
||||
numbers_per_line = 10
|
||||
numbers_in_row = 0
|
||||
|
||||
for num in range(1000, 3001):
|
||||
if num % 2 == 0 and num % 3 == 0 and num % 5 == 0:
|
||||
print(num, end=' ')
|
||||
count += 1
|
||||
numbers_in_row += 1
|
||||
|
||||
if numbers_in_row == numbers_per_line:
|
||||
print()
|
||||
numbers_in_row = 0
|
||||
|
||||
if numbers_in_row > 0:
|
||||
print()
|
||||
|
||||
print(f"Total numbers that are divisible by 2, 3, and 5: {count}")
|
||||
Reference in New Issue
Block a user