Python
Getting Started with Python
Python is one of the most popular and useful languages to learn.
Download https://www.python.org/downloads/
Run the installer
On Windows, click the Windows icon at the bottom left of the screen and type IDLE
One time:
Earlier versions: Options -> Configure IDLE -> General -> Open Edit Window, close and reopen
Latest version: Options -> Configure IDLE -> Windows -> Open Edit Window, close and reopen
Enter code into Edit Window
Run -> Run Module
For a more advanced IDE, use PyCharm
Top Web Resources
Think Python 2e free book
learnpython.org interactive tutorial
Python and Math
SageMathCell - for running Sage in browser
Structure / Style / Security
PEP 8 -- Style Guide for Python Code
Highlights
Maximum line length 79 characters
See Recommended Settings on the PyCharm page
Documentation
Docstrings
Complete sentences inside triple double quotes
One at the top of each file
a description of the file
__author__ = "Your Name" (not technically a docstring)
Example
"""My Sweet Integration Program"""
__author__ = "Jeff Lamont"
One under each function header
describe what the function does, not how
should include information about parameters and return values
Example
def get_bmr(height, weight):
"""The purpose of this function is to determine the user's basal metabolic rate (bmr) by asking a few questions and plugging them into a formula.
height - an integer in centimeters
weight - an integer in kilograms"""
Python Docstrings geeksforgeeks
If written properly, you can see the docstring from the interpreter or Python Console in PyCharm by importing the file name (without the file extension) and then typing help and the file name inside parentheses
import filename
help(filename)
help(filename.function_name)
Example
import Main
help(Main)
help(Main.calc_area)
The program should not run when you do import, if it does, you need to put all code in a function, use a main function, and replace the call to main with:
if __name__ == "__main__":
main()
Certification Exam Information
PCEP Entry-level
This exam mostly aligns with the COP 1500 required course content plus the optional data structures content
You can register for a proctored exam and go to a Testing Service facility or you can register for an unproctored exam. https://ums.edube.org/store
Prep
Python Essentials 1 – OpenEDG Learning & Testing Platform, self-enroll/self-study
Programming for Everybody (Getting Started with Python), course 1 in the Python for Everybody Specialization in Coursera. After clicking Enroll (for the course, not the specialization), click Audit the single course.
Python Data Structures, course 2 in the Python for Everybody Specialization in Coursera. After clicking Enroll (for the course, not the specialization), click Audit the single course.
PCAP Associate (higher level)
This exam includes everything in the PCEP exam in greater depth plus Classes and Exceptions, going well beyond the COP 1500 course content.
This exam must be taken at a Testing Service facility or through Pearson VUE/OnVUE online proctoring
Prep
Python Essentials 2 – OpenEDG Learning & Testing Platform, self-enroll/self-study
a 50% exam discount voucher is issued after completing the course