Mission Python by Sean McManus

Mission Python by Sean McManus

Author:Sean McManus
Language: eng
Format: epub
Publisher: No Starch Press
Published: 2018-11-01T16:00:00+00:00


➍ add(5, 7)

add(2012, 137)

add(1234, 4321)

Listing 8-1: Sending information to a function

Save the program as listing8-1.py. Because it doesn’t use any Pygame Zero features, you can run it by clicking Run ▸ Run Module or by pressing F5. (If you do run it using Pygame Zero, the results will appear in the command line window, and the game window will be empty.)

When you run the program, you should see the following output:

5 + 7 = 12

2012 + 137 = 2149

1234 + 4321 = 5555

We create a new function called add() ➊. After we’ve defined add(), we can run it by using its name ➍ and send it numbers by putting them in the parentheses, using commas between them ➍. The function will then add those two numbers.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.