Today, let's dive into how to create programs using logical thinking and solve real-world problems through programming.
- Lets us solve a case where thief was caught for pickpocket a purse who is caught by the police himself. While this case is interrogated in the court a lawyer continues to raise question to police how he caught the thief. Police replied when he heard a sound of theft from a crowd he saw a person running from that crowd then he said he started chasing him also stating that thief is 40 ft ahead of him. But he also stated that thief ran 2 ft every time also police ran 5 ft every time. And judge asked at what feet did the police caught the thief.
thief = 40
police = 0
while police < thief:
thief = thief + 2
police = police + 5
print(police)
2 loco pilot operates 2 trains from a point A to point B which has 30 station in-between. 1st loco pilot missed his food at stage A, 2nd loco pilot asked to give the food when he meets him at the first station. But there's a catch train 1 will stop every 3rd station and train 2 will stop every 5th station.
Find at which stop the 2nd loco pilot will hand over the food to loco pilot 1 ?
total = 30
stop = 1
while stop<=total:
if stop % 3 == 0 and stop % 5 == 0:
print(stop)
break
stop = stop + 1
Top comments (0)