7.7) Exercises 15 - If Statements
a: Copy the following program in a file and execute it.
answer = raw_input("Do you like the Rolling Stones (answer 'yes' or 'no')? ") if answer == "yes": print "Great, me too!" else: print "Fair enough."
b: Modify the program so that it answers:
- "Great, me too!" if the answer is "yes"
- "Fair enough." if the answer is "no"
- "I don't understand your answer." otherwise
Solution: exercise_music.py
c: At the restaurant:
- You order a starter, main and dessert of your choice
- The waiter brings you some dishes
- If the waiter brings you the correct three dishes, print 'Here’s a tip.'
- If the waiter makes a mistake in your order, print "I didn’t order x,y,z! I ordered X,Y,Z."
Solution: if_exercise_restaurant.py