Page 503 - ComputerScience_Class_11
P. 503
Program 12.py
File Edit Format Run Options Window Help
for i in range(1, 5):
for j in range(1, i+1):
print(j,end=' ')
print()
Output
1
1 2
1 2 3
1 2 3 4
Some More Programs
Program 1: A car starting from rest travels as follows:
• During its first 2 minute of motion, it travels at a velocity of 10 km/min.
• The next 8 minutes it travels at a velocity of 25 km/min.
• The next 10 minutes it travels at a velocity of 40 km/min.
• After that it continues to travel at a constant velocity of 60 km/min.
Write a program which takes the time in minutes and print distance travelled by the car in Kilo meter.
Program 1.py
File Edit Format Run Options Window Help
t=int(input('Enter time in minutes: '))
if t<=2:
d=t*10
elif t<=10:
d=2*10+(t-2)*25
elif t<=20:
d=2*10+8*25+(t-10)*40
else:
d=2*10+8*25+10*40+(t-20)*60
print('time in minutes:',t)
print('distance travelled in km:',d)
Output
Enter time in minutes: 20
time in minutes: 20
distance travelled in km: 620
Flow of Control 501

