Hardware Reference
In-Depth Information
Figure B-6:
IDLE running
Python code
from a file.
When you save your code, IDLE adds .py to the end of the filename. This is the file extension
for Python source files (just as Word adds .doc to documents).
TIP
Generating an Insult
Now that you've successfully run your first program, it's time to write something more inter-
esting - in this case, the computer will generate its own message to print. Type the following
code in a new file and then run it:
from random import choice
adjectives = [“wet”, “big”]
nouns = [“turnip”, “dog”]
print (“You are a”)
adjective = choice (adjectives)
print (adjective)
print (choice (nouns))
 
Search WWH ::




Custom Search