Difference between revisions of "CSC111 Homework 6 Solution 2014"
(→Program 3) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 09:46, 26 March 2014 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 09:46, 26 March 2014 (EDT) | ||
---- | ---- | ||
− | There were several good solution programs for [[CSC111 Homework 6 Solution 2014| Homework 6]]. You were not required to use a '''main()''' function, although some did. The | + | <onlydft> |
+ | |||
+ | There were several good solution programs for [[CSC111 Homework 6 Solution 2014| Homework 6]]. You were not required to use a '''main()''' function, although some did. The programs below were selected because they presented good features (not necessarily the same). | ||
<br /> | <br /> | ||
=Program 1= | =Program 1= | ||
+ | <br /> | ||
+ | The program below is a good example of how Python programs should be organized, with a header first, possibly a few import statements, maybe a constant or two, then a long list of function definitons ('''def''' statements), then the definition of the '''main()''' function, and at the very end, one call to '''main()''' that starts the whole program. | ||
<br /> | <br /> | ||
<source lang="python"> | <source lang="python"> | ||
Line 60: | Line 64: | ||
# ================================================================== | # ================================================================== | ||
− | # | + | # MAIN PROGRAM |
# ================================================================== | # ================================================================== | ||
# main()- set the visibility to be true and print the | # main()- set the visibility to be true and print the | ||
Line 209: | Line 213: | ||
</source> | </source> | ||
<br /> | <br /> | ||
+ | </onlydft> | ||
+ | |||
<br /> | <br /> | ||
<br /> | <br /> |