**14) Two trains stop at regular intervals:
Train 1 stops at every 3rd station.
Train 2 stops at every 5th station.
Find:
The first common station where both trains stop.
The last common station where both trains stop.
All common stations where both trains stop.
Note: The total number of stations is unknown.**
station = 3
last_station = 0
first_station = True
while station <= 80:
if station % 3 == 0 and station % 5 == 0:
if first_station == True:
print("First Common Station is", station)
first_station = False
last_station = station
print(station)
station+=1
print("Last Common Station is", last_station)
OUTPUT
First Common Station is 15
15
30
45
60
75
Last Common Station is 75
**15) A school is preparing a large square floor for its annual function. The floor has N tiles arranged in a single row. The teacher wants to divide these tiles into equal-sized groups without leaving any tile unused. For example, if there are 12 tiles, the teacher can make:
1 group of 12 tiles
2 groups of 6 tiles
3 groups of 4 tiles
4 groups of 3 tiles
6 groups of 2 tiles
12 groups of 1 tile
Write a Python program that takes the number of tiles N and finds all possible group sizes that can divide the tiles equally.**
no = 12
div = 1
while div <= no:
if no % div == 0:
print(div)
div+=1
OUTPUT
1
2
3
4
6
12
Top comments (0)