Python Lesson 7 Exercises: If ... elif ... else
In the following exercise, pay attention to your user interface, and be certain to test the codes to assure they work. Save each program as pa7-1.py, pa7-2.py and so forth.
Exercise 1:
Using the temperature conversion scripts you wrote in assignment 3 (pa3-5 and pa3-6), combine these two functions into a single program. The program should ask the user which conversion they want to do, then run that conversion function.
Exercise 2:
Edit the dice program from assignment 6 (pa6-3) so that it asks the user whether or not they want to roll again, then responds accordingly.
Exercise 3:
Create a basic black jack 21 game. The game should randomly deal two cards to the player and dealer. The player should be given one chance to choose another card, and the computer should decide whether or not to take another card. The player with the score closest to 21 will be declared the winner, while any player who goes over 21 will automatically lose.
Restricted access |