Game Development Reference
In-Depth Information
5 - Jokes
Who's there?
Interrupting cow.
Interrupting cow wh-MOO!
Joke's Source Code
Here is the source code for our short jokes program. Type it into the file editor and save
it as jokes.py . If you do not want to type this code in, you can also download the source
code from this topic's website at the URL http://inventwithpython.com/chapter5.
Important Note! Be sure to run this program with Python 3, and not Python 2. The
programs in this topic use Python 3, and you'll get errors if you try to run them with Python
2. You can click on Help and then About IDLE to find out what version of Python you
have.
jokes.py
This code can be downloaded from http://inventwithpython.com/jokes.py
If you get errors after typing this code in, compare it to the topic's code with the online
diff tool at http://inventwithpython.com/diff or email the author at
al@inventwithpython.com
1. print('What do you get when you cross a snowman with a
vampire?')
2. input()
3. print('Frostbite!')
4. print()
5. print('What do dentists call a astronaut\'s cavity?')
6. input()
7. print('A black hole!')
8. print()
9. print('Knock knock.')
10. input()
11. print("Who's there?")
12. input()
13. print('Interrupting cow.')
14. input()
15. print('Interrupting cow wh', end='')
16. print('-MOO!')
Don't worry if you don't understand everything in the program. Just save and run the
program. Remember, if your program has bugs in it, you can use the online diff tool at
http://inventwithpython.com/chapter5.
How the Code Works
Let's look at the code more carefully.
Search WWH ::




Custom Search