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

Structure / Style / Security

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

  • PEP 257 -- Docstring Conventions

  • 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()

More info

Certification Exam Information

PCEP Entry-level

PCAP Associate (higher level)

  • Exam information

  • 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