Program 001

mine1

car_sta=’park’
command=input(‘>’)
while command !=’quit’:
if command == ‘help’:
print(”’
start – to start car
stop – to stop car
quit – to quit the game”’)
command=input(‘>’)
elif command==’stop’ and car_sta==’park’:
print(‘car is not running yet’)
command=input(‘>’)
elif command==’stop’ and car_sta==’run’:
print(‘car stopped’)
car_sta=’park’
command=input(‘>’)
elif command==’start’ and car_sta==’park’:
print(‘car is running now!’)
car_sta=’run’
command=input(‘>’)
elif command==’start’ and car_sta==’run’:
print(‘car is running already!’)
command=input(‘>’)
else:
print(‘I do not understand!’)
command=input(‘>’)
else:
print (‘end’)

mine2

car_run = False
command=input(‘>’)
while command !=’quit’:
if command == ‘help’:
print(”’
start – to start car
stop – to stop car
quit – to quit the game
”’)
command=input(‘>’)
elif command==’stop’ and car_run == False:
print(‘car is not running yet’)
command=input(‘>’)
elif command==’stop’ and car_run == True:
print(‘car stopped’)
car_run=False
command=input(‘>’)
elif command==’start’ and car_run == False:
print(‘car is running now!’)
car_run=True
command=input(‘>’)
elif command==’start’ and car_run == True:
print(‘car is running already!’)
command=input(‘>’)
else:
print(‘I do not understand!’)
command=input(‘>’)
else:
print (‘end’)

Leave a Reply