Skip to main content

if_exercise_restaurant.py


"""
Exercise, if statements: At the restaurant.
- You order a starter, main and desert of your choice.
Define a list with the three elements of your order.
- The waiter brings you some dishes.
Define a list with the three elements of the waiter brings.
- If the waiter brings you the correct three dishes, print 'Give a tip.'
- If the waiter makes a mistake in your order,
print 'I didn't order x,y,z! I ordered X,Y,Z!'
Author: L J Gregoire
"""
# seperate variables
order_starter='soup'
order_main='burger'
order_desert='brownie'
print 'What would you like to eat?'
print 'I would like',order_starter,',',order_main,'and',order_desert
starter='natchos'
main='curry'
desert='ice cream'
if (starter==order_starter and main==order_main and desert==order_desert):
    print "Here's a tip!"
else:
    print "I didn't order",starter,',',main,'and',desert
    print "I ordered",order_starter,',',order_main,'and',order_desert
print 'Goodbye!'
## version with lists
order=['soup','burger','brownie']
print 'What would you like to eat?'
print 'I would like',order[0],',',order[1],'and',order[2]
brought=['natchos','curry','ice cream']
if brought == order:
            print "Here's a tip!"
else:
    print "I didn't order",brought[0],',',brought[1],'and',brought[2]
    print "I ordered",order[0],',',order[1],'and',order[2]
print 'Goodbye!'